@@ -83,7 +83,11 @@ export default class MP4Player extends EventEmitter {
8383 if ( this . currentAudioTrack !== null ) {
8484 const audioTrack = this . metaData . audioTracks [ this . currentAudioTrack ] ;
8585 if ( audioTrack ) {
86- const audioCodec = 'audio/mp4; codecs=\"' + audioTrack . codec + '\"' ;
86+ let fixedCodec = audioTrack . codec ;
87+ if ( fixedCodec === 'Opus' ) {
88+ fixedCodec = 'opus' ;
89+ }
90+ const audioCodec = 'audio/mp4; codecs=\"' + fixedCodec + '\"' ;
8791 this . audioSourceBuffer = new SourceBufferWrapper ( this . mediaSource , audioCodec ) ;
8892 }
8993 }
@@ -102,7 +106,12 @@ export default class MP4Player extends EventEmitter {
102106
103107 setupHLS ( ) {
104108 this . removeSourceBuffers ( ) ;
105- this . makeSourceBuffers ( ) ;
109+ try {
110+ this . makeSourceBuffers ( ) ;
111+ } catch ( e ) {
112+ this . emit ( DefaultPlayerEvents . ERROR , 'Failed to create SourceBuffers: ' + e . message ) ;
113+ return ;
114+ }
106115
107116 this . mp4box . fragmentedTracks . length = 0 ;
108117
@@ -432,10 +441,12 @@ export default class MP4Player extends EventEmitter {
432441
433442 if ( ! this . metaData ) {
434443 const nextParsePosition = this . mp4box . nextParsePosition || ( frag . rangeEnd + 1 ) ;
435- const fragIndex = Math . floor ( nextParsePosition / FRAGMENT_SIZE ) ;
444+ const maxIndex = Math . floor ( nextParsePosition / FRAGMENT_SIZE ) ;
436445 const levelID = this . getCurrentVideoLevelID ( ) ;
437- if ( ! this . client . getFragment ( levelID , fragIndex ) ) {
438- this . client . makeFragment ( levelID , fragIndex , new MP4Fragment ( levelID , fragIndex , this . source , fragIndex * FRAGMENT_SIZE , ( fragIndex + 1 ) * FRAGMENT_SIZE ) ) ;
446+ for ( let fragIndex = 1 ; fragIndex <= maxIndex ; fragIndex ++ ) {
447+ if ( ! this . client . getFragment ( levelID , fragIndex ) ) {
448+ this . client . makeFragment ( levelID , fragIndex , new MP4Fragment ( levelID , fragIndex , this . source , fragIndex * FRAGMENT_SIZE , ( fragIndex + 1 ) * FRAGMENT_SIZE ) ) ;
449+ }
439450 }
440451 } else {
441452 console . log ( entry . responseHeaders ) ;
0 commit comments