@@ -933,6 +933,8 @@ class AlertPlayer {
933933 eventData : any ;
934934 skipReason ?: string ;
935935 } ) {
936+ this . currentlyPlaying = event ;
937+
936938 const onEnd = ( ) => {
937939 console . log ( 'Stop Playing' ) ;
938940 this . stopPlaying ( ) ;
@@ -961,11 +963,12 @@ class AlertPlayer {
961963
962964 this . startPlaying ( ) ;
963965 // Direct access to blerp audio without proxy
964- this . getAudioInfo ( alertInfo . audioUrl ! ) . then ( ( audioInfo ) => {
965- PubSub . publish ( 'AlertPlayer-update' , { duration : audioInfo ?. duration || 5 } ) ; // Default to 5 seconds if duration unknown
966- this . playAudio ( 1.0 , audioInfo , 0 ) . then ( onEnd , onError ) ;
967- } , onError ) ;
968- return ;
966+ return new Promise < void > ( ( resolve , reject ) => {
967+ this . getAudioInfo ( alertInfo . audioUrl ! ) . then ( ( audioInfo ) => {
968+ PubSub . publish ( 'AlertPlayer-update' , { duration : audioInfo ?. duration || 5 } ) ;
969+ this . playAudio ( 1.0 , audioInfo , 0 ) . then ( ( ) => { onEnd ( ) ; resolve ( ) ; } , ( err ) => { onError ( err ) ; reject ( err ) ; } ) ;
970+ } , ( err ) => { onError ( err ) ; reject ( err ) ; } ) ;
971+ } ) ;
969972 }
970973
971974 // Handle soundalerts (direct audio URL)
@@ -982,11 +985,12 @@ class AlertPlayer {
982985 }
983986
984987 this . startPlaying ( ) ;
985- this . getAudioInfo ( alertInfo . audioUrl ! ) . then ( ( audioInfo ) => {
986- PubSub . publish ( 'AlertPlayer-update' , { duration : audioInfo ?. duration || 5 } ) ;
987- this . playAudio ( 1.0 , audioInfo , 0 ) . then ( onEnd , onError ) ;
988- } , onError ) ;
989- return ;
988+ return new Promise < void > ( ( resolve , reject ) => {
989+ this . getAudioInfo ( alertInfo . audioUrl ! ) . then ( ( audioInfo ) => {
990+ PubSub . publish ( 'AlertPlayer-update' , { duration : audioInfo ?. duration || 5 } ) ;
991+ this . playAudio ( 1.0 , audioInfo , 0 ) . then ( ( ) => { onEnd ( ) ; resolve ( ) ; } , ( err ) => { onError ( err ) ; reject ( err ) ; } ) ;
992+ } , ( err ) => { onError ( err ) ; reject ( err ) ; } ) ;
993+ } ) ;
990994 }
991995
992996 // At this point we have a standard alert
@@ -1014,7 +1018,6 @@ class AlertPlayer {
10141018 const sink = localStorage . getItem ( 'hehe-sink' ) || '' ;
10151019 this . startPlaying ( ) ;
10161020 console . log ( 'Start playing' ) ;
1017- this . currentlyPlaying = event ;
10181021 const ttsMessage = this . cleanMessage ( formatString ( alert . audio ?. tts ?. text || "" , {
10191022 ...vars ,
10201023 text : ( eventData && eventData . text ) ? this . parsedPartsToTTSText ( eventData . text . parts || eventData . text ) : undefined
0 commit comments