@@ -27,7 +27,7 @@ export function ExternalAudioPanel({
2727 const [ currentTime , setCurrentTime ] = useState < number > ( ) ;
2828 const [ duration , setDuration ] = useState < number > ( ) ;
2929 const [ volume , setVolume ] = useState ( 100 ) ;
30- const [ status , setStatus ] = useState ( "YouTube audio is active" ) ; // TODO: Reserve status for actionable errors.
30+ const [ error , setError ] = useState < string > ( ) ;
3131
3232 useEffect ( ( ) => {
3333 const audio = document . createElement ( "audio" ) ;
@@ -77,7 +77,7 @@ export function ExternalAudioPanel({
7777 setEnabled ( false ) ;
7878 setCurrentTime ( 0 ) ;
7979 setDuration ( undefined ) ;
80- setStatus ( "Ready; YouTube audio is active" ) ;
80+ setError ( undefined ) ;
8181 }
8282
8383 function changeVolume ( nextVolume : number ) {
@@ -93,25 +93,25 @@ export function ExternalAudioPanel({
9393 sync . destroy ( ) ;
9494 syncRef . current = null ;
9595 setEnabled ( false ) ;
96- setStatus ( "YouTube audio is active" ) ;
96+ setError ( undefined ) ;
9797 return ;
9898 }
9999
100100 const video = getVideo ( ) ;
101101 const audio = audioRef . current ;
102102 if ( ! video || ! audio ) {
103- setStatus ( "YouTube video element not found") ;
103+ setError ( "Video source not found") ;
104104 return ;
105105 }
106106
107107 const nextSync = new PlayerSync ( video , audio , ( error ) => {
108- setStatus ( `Playback failed: ${ String ( error ) } ` ) ;
108+ setError ( `Playback failed: ${ String ( error ) } ` ) ;
109109 } ) ;
110110 nextSync . enable ( ) ;
111111 syncRef . current = nextSync ;
112112 setCurrentTime ( audio . currentTime ) ;
113113 setEnabled ( true ) ;
114- setStatus ( "External audio is active" ) ;
114+ setError ( undefined ) ;
115115 }
116116
117117 return (
@@ -159,7 +159,11 @@ export function ExternalAudioPanel({
159159 />
160160 < span className = "w-9 text-right font-mono tabular-nums" > { volume } %</ span >
161161 </ label >
162- < div className = "mt-2 truncate text-muted-foreground" > { status } </ div >
162+ { error && (
163+ < div className = "mt-2 text-error" role = "alert" >
164+ { error }
165+ </ div >
166+ ) }
163167 < input
164168 ref = { inputRef }
165169 type = "file"
0 commit comments