@@ -133,7 +133,7 @@ function PlayerComponent(
133133 return genericADAvailable ? genericADEnabled : playbackStrategyProvidedAD ( )
134134 }
135135
136- function genericAudioDescribedSwitch ( to ) {
136+ function genericAudioDescribedSwitch ( enable ) {
137137 const wasPaused = isPaused ( )
138138 const presentationTimeInSeconds = getCurrentTime ( )
139139 const availabilityTimeInMilliseconds = presentationTimeToAvailabilityTimeInMilliseconds (
@@ -142,7 +142,7 @@ function PlayerComponent(
142142 )
143143
144144 return mediaSources
145- . setAudioDescribed ( to )
145+ . setAudioDescribed ( enable )
146146 . then ( ( ) => {
147147 const presentationTimeInSeconds = availabilityTimeToPresentationTimeInSeconds (
148148 availabilityTimeInMilliseconds ,
@@ -155,16 +155,20 @@ function PlayerComponent(
155155 . catch ( ( ) => {
156156 bubbleFatalError ( false , {
157157 code : "0000" ,
158- message : `error switching ${ to ? "to" : "from" } audio described` ,
158+ message : `error switching ${ enable ? "to" : "from" } audio described` ,
159159 } )
160160 } )
161161 }
162162
163- function setAudioDescribed ( to ) {
164- if ( mediaSources . isAudioDescribedAvailable ( ) ) return genericAudioDescribedSwitch ( to )
165- if ( ! ( playbackStrategy && playbackStrategy . isAudioDescribedAvailable ?. ( ) ) ) return Promise . resolve ( )
163+ function setAudioDescribed ( enable ) {
164+ if ( mediaSources . isAudioDescribedAvailable ( ) ) return genericAudioDescribedSwitch ( enable )
165+
166+ if ( playbackStrategy ) {
167+ if ( ! playbackStrategy . isAudioDescribedAvailable ?. ( ) ) return Promise . resolve ( )
168+
169+ enable ? playbackStrategy . setAudioDescribedOn ?. ( ) : playbackStrategy . setAudioDescribedOff ?. ( )
170+ }
166171
167- playbackStrategy && playbackStrategy [ to ? "setAudioDescribedOn" : "setAudioDescribedOff" ] ?. ( )
168172 return Promise . resolve ( )
169173 }
170174
0 commit comments