@@ -13,45 +13,67 @@ function TrackSwitchConfig({
1313 onDefaultAudioTrackSwitchingModeChange,
1414 onCodecSwitchChange,
1515 onEnableFastSwitchingChange,
16+ onAudioTracksNotPlayable,
17+ onAudioTracksNotPlayableChange,
18+ onVideoTracksNotPlayable,
19+ onVideoTracksNotPlayableChange,
1620} : {
1721 defaultAudioTrackSwitchingMode : string ;
1822 onDefaultAudioTrackSwitchingModeChange : ( newVal : string ) => void ;
1923 enableFastSwitching : boolean ;
2024 onCodecSwitch : string ;
2125 onCodecSwitchChange : ( val : string ) => void ;
2226 onEnableFastSwitchingChange : ( val : boolean ) => void ;
27+ onAudioTracksNotPlayable : string ;
28+ onAudioTracksNotPlayableChange : ( val : string ) => void ;
29+ onVideoTracksNotPlayable : string ;
30+ onVideoTracksNotPlayableChange : ( val : string ) => void ;
2331} ) : React . JSX . Element {
24- let defaultAudioTrackSwitchingModeDescMsg ;
25- switch ( defaultAudioTrackSwitchingMode ) {
26- case "reload" :
27- defaultAudioTrackSwitchingModeDescMsg =
28- "Reloading by default when the audio track is changed" ;
29- break ;
30- case "direct" :
31- defaultAudioTrackSwitchingModeDescMsg =
32- "Directly audible transition when the audio track is changed" ;
33- break ;
34- case "seamless" :
35- defaultAudioTrackSwitchingModeDescMsg =
36- "Smooth transition when the audio track is changed" ;
37- break ;
38- default :
39- defaultAudioTrackSwitchingModeDescMsg = "Unknown value" ;
40- break ;
41- }
32+ const defaultAudioTrackSwitchingModeDescMsg = React . useMemo ( ( ) => {
33+ switch ( defaultAudioTrackSwitchingMode ) {
34+ case "reload" :
35+ return "Reloading by default when the audio track is changed" ;
36+ case "direct" :
37+ return "Directly audible transition when the audio track is changed" ;
38+ case "seamless" :
39+ return "Smooth transition when the audio track is changed" ;
40+ default :
41+ return "Unknown value" ;
42+ }
43+ } , [ defaultAudioTrackSwitchingMode ] ) ;
4244
43- let onCodecSwitchDescMsg ;
44- switch ( onCodecSwitch ) {
45- case "reload" :
46- onCodecSwitchDescMsg = "Reloading buffers when the codec changes" ;
47- break ;
48- case "continue" :
49- onCodecSwitchDescMsg = "Keeping the same buffers even when the codec changes" ;
50- break ;
51- default :
52- onCodecSwitchDescMsg = "Unknown value" ;
53- break ;
54- }
45+ const onCodecSwitchDescMsg = React . useMemo ( ( ) => {
46+ switch ( onCodecSwitch ) {
47+ case "reload" :
48+ return "Reloading buffers when the codec changes" ;
49+ case "continue" :
50+ return "Keeping the same buffers even when the codec changes" ;
51+ default :
52+ return "Unknown value" ;
53+ }
54+ } , [ onCodecSwitch ] ) ;
55+
56+ const onAudioTracksNotPlayableDescMsg = React . useMemo ( ( ) => {
57+ switch ( onAudioTracksNotPlayable ) {
58+ case "error" :
59+ return "Throw an error if no audio track can be played" ;
60+ case "continue" :
61+ return "Continue with video only if no audio track is playable" ;
62+ default :
63+ return "Unknown value" ;
64+ }
65+ } , [ onAudioTracksNotPlayable ] ) ;
66+
67+ const onVideoTracksNotPlayableDescMsg = React . useMemo ( ( ) => {
68+ switch ( onVideoTracksNotPlayable ) {
69+ case "error" :
70+ return "Throw an error if no video track can be played" ;
71+ case "continue" :
72+ return "Continue with audio only if no video track is playable" ;
73+ default :
74+ return "Unknown value" ;
75+ }
76+ } , [ onVideoTracksNotPlayable ] ) ;
5577
5678 const onCodecSwitchSelection = React . useCallback (
5779 ( { value } : { value : string } ) => onCodecSwitchChange ( value ) ,
@@ -63,6 +85,16 @@ function TrackSwitchConfig({
6385 [ onDefaultAudioTrackSwitchingModeChange ] ,
6486 ) ;
6587
88+ const onAudioTracksNotPlayableSelection = React . useCallback (
89+ ( { value } : { value : string } ) => onAudioTracksNotPlayableChange ( value ) ,
90+ [ onAudioTracksNotPlayableChange ] ,
91+ ) ;
92+
93+ const onVideoTracksNotPlayableSelection = React . useCallback (
94+ ( { value } : { value : string } ) => onVideoTracksNotPlayableChange ( value ) ,
95+ [ onVideoTracksNotPlayableChange ] ,
96+ ) ;
97+
6698 return (
6799 < >
68100 < li >
@@ -109,6 +141,35 @@ function TrackSwitchConfig({
109141 </ Select >
110142 < span className = "option-desc" > { onCodecSwitchDescMsg } </ span >
111143 </ li >
144+ < li className = "featureWrapperWithSelectMode" >
145+ < Select
146+ ariaLabel = "Selecting the onAudioTracksNotPlayable attribute"
147+ disabled = { false }
148+ className = "playerOptionInput"
149+ name = "onAudioTracksNotPlayable"
150+ onChange = { onAudioTracksNotPlayableSelection }
151+ selected = { { value : onAudioTracksNotPlayable , index : undefined } }
152+ options = { [ "continue" , "error" ] }
153+ >
154+ On Audio Tracks Not Playable
155+ </ Select >
156+ < span className = "option-desc" > { onAudioTracksNotPlayableDescMsg } </ span >
157+ </ li >
158+
159+ < li className = "featureWrapperWithSelectMode" >
160+ < Select
161+ ariaLabel = "Selecting the onVideoTracksNotPlayable attribute"
162+ disabled = { false }
163+ className = "playerOptionInput"
164+ name = "onVideoTracksNotPlayable"
165+ onChange = { onVideoTracksNotPlayableSelection }
166+ selected = { { value : onVideoTracksNotPlayable , index : undefined } }
167+ options = { [ "continue" , "error" ] }
168+ >
169+ On Video Tracks Not Playable
170+ </ Select >
171+ < span className = "option-desc" > { onVideoTracksNotPlayableDescMsg } </ span >
172+ </ li >
112173 </ >
113174 ) ;
114175}
0 commit comments