File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 2012
2012
*/
2013
2013
_endListener : function ( ) {
2014
2014
var self = this ;
2015
+ var parent = self . _parent ;
2016
+
2017
+ // This event should fire only when the audio ended despite being marked infinite by the browser
2018
+ if ( parent . _duration === Infinity ) {
2019
+
2020
+ // Update the parent duration to match the real audio duration
2021
+ // Round up the duration to account for the lower precision in HTML5 Audio.
2022
+ parent . _duration = Math . ceil ( self . _node . duration * 10 ) / 10 ;
2023
+
2024
+ // Setup a sprite that corresponds to the real duration.
2025
+ if ( parent . _sprite . __default [ 1 ] === Infinity ) {
2026
+ parent . _sprite . __default [ 1 ] = parent . _duration * 1000 ;
2027
+ }
2015
2028
2016
- // Fire an end event - the duration should have been infinite but the audio ended anyways.
2017
- if ( self . _parent . _duration === Infinity ) {
2018
- self . _parent . _ended ( self ) ;
2029
+ parent . _ended ( self ) ;
2019
2030
}
2020
2031
2021
2032
// Clear the event listener.
You can’t perform that action at this time.
0 commit comments