File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ module.exports.Component = registerComponent('sound', {
9191
9292 // Remove this key from cache, otherwise we can't play it again
9393 THREE . Cache . remove ( data . src ) ;
94- if ( self . data . autoplay || self . mustPlay ) { self . playSound ( this . processSound ) ; }
94+ if ( self . data . autoplay || self . mustPlay ) { self . playSound ( self . processSound ) ; }
9595 self . el . emit ( 'sound-loaded' , self . evtDetail , false ) ;
9696 } ) ;
9797 }
Original file line number Diff line number Diff line change @@ -176,6 +176,23 @@ suite('sound', function () {
176176 assert . ok ( sound . play . called ) ;
177177 } ) ;
178178
179+ test ( 'plays sound and calls processSound callback when not loaded' , function ( done ) {
180+ var el = this . el ;
181+ var processSoundStub = sinon . stub ( ) ;
182+
183+ el . setAttribute ( 'sound' , 'src' , 'url(base/tests/assets/test.ogg)' ) ;
184+ el . components . sound . playSound ( processSoundStub ) ;
185+ assert . notOk ( el . components . sound . isPlaying ) ;
186+ assert . ok ( el . components . sound . mustPlay ) ;
187+
188+ el . addEventListener ( 'sound-loaded' , function ( ) {
189+ assert . ok ( el . components . sound . isPlaying ) ;
190+ assert . notOk ( el . components . sound . mustPlay ) ;
191+ assert . ok ( processSoundStub . calledOnce ) ;
192+ done ( ) ;
193+ } ) ;
194+ } ) ;
195+
179196 test ( 'plays sound if sound already playing when changing src' , function ( done ) {
180197 var el = this . el ;
181198 var playSoundStub = el . components . sound . playSound = sinon . stub ( ) ;
You can’t perform that action at this time.
0 commit comments