@@ -514,13 +514,16 @@ function MSEStrategy(
514514 function onCurrentTrackChanged ( event ) {
515515 if ( ! isAudioDescribedAvailable ( ) ) return
516516
517+ audioDescribed . enable = isAudioDescribedEnabled ( )
517518 const mediaType = event . newMediaInfo . type
519+
518520 DebugTool . info (
519521 `${ mediaType } track changed.${
520- mediaType === "audio" ? ( isAudioDescribedEnabled ( ) ? " Audio Described on." : " Audio Described off." ) : ""
522+ mediaType === "audio" ? ( audioDescribed . enable ? " Audio Described on." : " Audio Described off." ) : ""
521523 } `
522524 )
523- audioDescribed . callback && audioDescribed . callback ( isAudioDescribedEnabled ( ) )
525+
526+ audioDescribed . callback && audioDescribed . callback ( audioDescribed . enable )
524527 }
525528
526529 function publishMediaState ( mediaState ) {
@@ -600,6 +603,16 @@ function MSEStrategy(
600603
601604 mediaPlayer . initialize ( mediaElement , null )
602605
606+ modifySource ( presentationTimeInSeconds , embeddedSubs )
607+ }
608+
609+ function modifySource ( presentationTimeInSeconds , embeddedSubs ) {
610+ if ( mediaPlayer . isReady ( ) ) {
611+ // Reset source to apply media settings for the new source
612+ // dash.js will reset media settings if a new source is attached while its initialised with a source
613+ mediaPlayer . attachSource ( null )
614+ }
615+
603616 mediaPlayer . setInitialMediaSettingsFor (
604617 "audio" ,
605618 audioDescribed . enable
@@ -612,18 +625,15 @@ function MSEStrategy(
612625 }
613626 )
614627
628+ const source = mediaSources . currentSource ( )
629+ const anchor = buildSourceAnchor ( presentationTimeInSeconds )
630+
631+ mediaPlayer . attachSource ( `${ source } ${ anchor } ` )
632+
615633 if ( embeddedSubs ) {
616634 setUpSubtitleElement ( playbackElement )
617635 mediaPlayer . attachTTMLRenderingDiv ( subtitleElement )
618636 }
619-
620- modifySource ( presentationTimeInSeconds )
621- }
622-
623- function modifySource ( presentationTimeInSeconds ) {
624- const source = mediaSources . currentSource ( )
625- const anchor = buildSourceAnchor ( presentationTimeInSeconds )
626- mediaPlayer . attachSource ( `${ source } ${ anchor } ` )
627637 }
628638
629639 /**
0 commit comments