@@ -321,7 +321,7 @@ function sepiaFW_build_audio(){
321321 //---- broadcasting -----
322322
323323 AudioPlayer . broadcastAudioEvent = function ( source , action , playerObject ) {
324- //stream, effects, tts-player, unknown - start, stop, error, fadeOut, fadeIn
324+ //stream, effects, tts-player, unknown - prepare, start, stop, error, fadeOut, fadeIn
325325 //android-intent - stop, start
326326 //youtube-embedded - start, resume, pause, hold
327327 source = source . toLowerCase ( ) ;
@@ -333,7 +333,7 @@ function sepiaFW_build_audio(){
333333 source : source ,
334334 action : action
335335 } } ) ;
336- document . dispatchEvent ( event ) ;
336+ document . dispatchEvent ( event ) ; //NOTE: we could check result for 'prevent default' (its sync.)
337337 //console.error("audio event: " + source + " - " + action);
338338 }
339339
@@ -832,11 +832,13 @@ function sepiaFW_build_audio(){
832832 } else if ( audioPlayer === 'tts' ) {
833833 audioPlayer = speaker ;
834834 }
835- if ( audioURL ) audioURL = SepiaFW . config . replacePathTagWithActualPath ( audioURL ) ;
836-
835+ var sourceName = "unknown" ;
837836 var audioOnEndFired = false ; //prevent doublefireing of audio onend onpause
838837
838+ if ( audioURL ) audioURL = SepiaFW . config . replacePathTagWithActualPath ( audioURL ) ;
839+
839840 if ( audioPlayer == player ) {
841+ sourceName = "stream" ;
840842 if ( audioURL ) {
841843 beforeLastAudioStream = lastAudioStream ;
842844 lastAudioStream = audioURL ;
@@ -857,9 +859,11 @@ function sepiaFW_build_audio(){
857859 Stream . isLoading = true ;
858860
859861 } else if ( audioPlayer == player2 ) {
862+ sourceName = "effects" ;
860863 //TODO: ?
861864
862865 } else if ( audioPlayer == speaker ) {
866+ sourceName = "tts-player" ;
863867 if ( isVoiceEffectSetupPending ) {
864868 //TODO: delay
865869 SepiaFW . debug . error ( "AUDIO: voice-effects setup still pending! Should delay 'AudioPlayer.playURL'" ) ; //debug
@@ -878,6 +882,7 @@ function sepiaFW_build_audio(){
878882 }
879883
880884 audioPlayer . preload = 'auto' ;
885+ AudioPlayer . broadcastAudioEvent ( sourceName , "prepare" , audioPlayer ) ;
881886
882887 //console.log("Audio-URL: " + audioURL); //DEBUG
883888 audioPlayer . src = audioURL ;
@@ -898,15 +903,7 @@ function sepiaFW_build_audio(){
898903 }
899904 //callback
900905 if ( onStartCallback ) onStartCallback ( ) ;
901- if ( audioPlayer == player ) {
902- AudioPlayer . broadcastAudioEvent ( "stream" , "start" , audioPlayer ) ;
903- } else if ( audioPlayer == player2 ) {
904- AudioPlayer . broadcastAudioEvent ( "effects" , "start" , audioPlayer ) ;
905- } else if ( audioPlayer == speaker ) {
906- AudioPlayer . broadcastAudioEvent ( "tts-player" , "start" , audioPlayer ) ;
907- } else {
908- AudioPlayer . broadcastAudioEvent ( "unknown" , "start" , audioPlayer ) ;
909- }
906+ AudioPlayer . broadcastAudioEvent ( sourceName , "start" , audioPlayer ) ;
910907 } ;
911908 audioPlayer . onpause = function ( ) {
912909 if ( ! audioOnEndFired ) {
@@ -926,15 +923,15 @@ function sepiaFW_build_audio(){
926923 }
927924 //callback
928925 if ( onEndCallback ) onEndCallback ( ) ;
926+ var sourceName = "unknown" ;
929927 if ( audioPlayer == player ) {
930- AudioPlayer . broadcastAudioEvent ( "stream" , "stop" , audioPlayer ) ;
928+ sourceName = "stream" ;
931929 } else if ( audioPlayer == player2 ) {
932- AudioPlayer . broadcastAudioEvent ( "effects" , "stop" , audioPlayer ) ;
930+ sourceName = "effects" ;
933931 } else if ( audioPlayer == speaker ) {
934- AudioPlayer . broadcastAudioEvent ( "tts-player" , "stop" , audioPlayer ) ;
935- } else {
936- AudioPlayer . broadcastAudioEvent ( "unknown" , "stop" , audioPlayer ) ;
932+ sourceName = "tts-player" ;
937933 }
934+ AudioPlayer . broadcastAudioEvent ( sourceName , "stop" , audioPlayer ) ;
938935 }
939936 } ;
940937 audioPlayer . onended = function ( ) {
@@ -966,15 +963,15 @@ function sepiaFW_build_audio(){
966963 }
967964 //callback
968965 if ( onErrorCallback ) onErrorCallback ( ) ;
966+ var sourceName = "unknown" ;
969967 if ( audioPlayer == player ) {
970- AudioPlayer . broadcastAudioEvent ( "stream" , "error" , audioPlayer ) ;
968+ sourceName = "stream" ;
971969 } else if ( audioPlayer == player2 ) {
972- AudioPlayer . broadcastAudioEvent ( "effects" , "error" , audioPlayer ) ;
970+ sourceName = "effects" ;
973971 } else if ( audioPlayer == speaker ) {
974- AudioPlayer . broadcastAudioEvent ( "tts-player" , "error" , audioPlayer ) ;
975- } else {
976- AudioPlayer . broadcastAudioEvent ( "unknown" , "error" , audioPlayer ) ;
972+ sourceName = "tts-player" ;
977973 }
974+ AudioPlayer . broadcastAudioEvent ( sourceName , "error" , audioPlayer ) ;
978975 } ;
979976 var p = audioPlayer . play ( ) ;
980977 if ( p && ( 'catch' in p ) ) {
@@ -1046,6 +1043,7 @@ function sepiaFW_build_audio(){
10461043 }
10471044
10481045 var audioOnEndFired = false ;
1046+ AudioPlayer . broadcastAudioEvent ( "effects" , "prepare" , audioPlayer ) ;
10491047
10501048 audioPlayer . src = alarmSound ;
10511049 audioPlayer . preload = 'auto' ;
0 commit comments