File tree 1 file changed +18
-7
lines changed
1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change 723
723
sound . _stop = ( self . _sprite [ sprite ] [ 0 ] + self . _sprite [ sprite ] [ 1 ] ) / 1000 ;
724
724
sound . _loop = ! ! ( sound . _loop || self . _sprite [ sprite ] [ 2 ] ) ;
725
725
726
+ // End the sound instantly if seek is at the end.
727
+ if ( sound . _seek >= sound . _stop ) {
728
+ self . _ended ( sound ) ;
729
+ return ;
730
+ }
731
+
726
732
// Begin the actual playback.
727
733
var node = sound . _node ;
728
734
if ( self . _webAudio ) {
1470
1476
sound . _ended = false ;
1471
1477
self . _clearTimer ( id ) ;
1472
1478
1473
- // Restart the playback if the sound was playing.
1474
- if ( playing ) {
1475
- self . play ( id , true ) ;
1476
- }
1477
-
1478
1479
// Update the seek position for HTML5 Audio.
1479
1480
if ( ! self . _webAudio && sound . _node ) {
1480
1481
sound . _node . currentTime = seek ;
1481
1482
}
1482
1483
1484
+ // Seek and emit when ready.
1485
+ var seekAndEmit = function ( ) {
1486
+ self . _emit ( 'seek' , id ) ;
1487
+
1488
+ // Restart the playback if the sound was playing.
1489
+ if ( playing ) {
1490
+ self . play ( id , true ) ;
1491
+ }
1492
+ } ;
1493
+
1483
1494
// Wait for the play lock to be unset before emitting (HTML5 Audio).
1484
1495
if ( playing && ! self . _webAudio ) {
1485
1496
var emitSeek = function ( ) {
1486
1497
if ( ! self . _playLock ) {
1487
- self . _emit ( 'seek' , id ) ;
1498
+ seekAndEmit ( ) ;
1488
1499
} else {
1489
1500
setTimeout ( emitSeek , 0 ) ;
1490
1501
}
1491
1502
} ;
1492
1503
setTimeout ( emitSeek , 0 ) ;
1493
1504
} else {
1494
- self . _emit ( 'seek' , id ) ;
1505
+ seekAndEmit ( ) ;
1495
1506
}
1496
1507
} else {
1497
1508
if ( self . _webAudio ) {
You can’t perform that action at this time.
0 commit comments