@@ -248,12 +248,13 @@ function sepiaFW_build_audio(){
248248 && ( ( new Date ( ) . getTime ( ) - SepiaFW . android . lastReceivedMediaAppTS ) < ( 1000 * 60 * 15 ) ) ; //This is pure guessing ...
249249 return isInternalPlayerStreaming || isEmbeddedMediaPlayerStreaming || isAndroidPlayerStreaming ;
250250 }
251- AudioPlayer . getLastActiveAudioStreamPlayer = function ( ) {
251+ AudioPlayer . getLastActiveAudioSource = function ( ) {
252252 return lastAudioPlayerEventSource ;
253253 }
254254
255255 //controls
256256 var audioTitle ;
257+ var currentAudioTitleBelongsToStreamPlayer = true ; //default: true
257258 var audioStartBtn ;
258259 var audioStopBtn ;
259260 var audioVolUp ;
@@ -395,24 +396,38 @@ function sepiaFW_build_audio(){
395396 audioTitle = document . getElementById ( 'sepiaFW-audio-ctrls-title' ) ;
396397 audioStartBtn = document . getElementById ( 'sepiaFW-audio-ctrls-start' ) ;
397398 $ ( audioStartBtn ) . off ( ) . on ( 'click' , function ( ) {
398- //NOTE: for now this is "internal" player only (as volume control)
399- if ( ! AudioPlayer . initAudio ( function ( ) { AudioPlayer . playURL ( '' , player ) ; } ) ) {
400- AudioPlayer . playURL ( '' , player ) ;
401- }
399+ AudioPlayer . initAudio ( undefined , function ( ) {
400+ if ( currentAudioTitleBelongsToStreamPlayer ) {
401+ //we keep this for now...
402+ AudioPlayer . playURL ( '' , "stream" ) ;
403+ } else {
404+ SepiaFW . client . controls . media ( {
405+ action : "resume" ,
406+ skipFollowUp : true
407+ } ) ;
408+ }
409+ } ) ;
402410 } ) ;
403411 audioStopBtn = document . getElementById ( 'sepiaFW-audio-ctrls-stop' ) ;
404412 $ ( audioStopBtn ) . off ( ) . on ( 'click' , function ( ) {
405413 SepiaFW . client . controls . media ( {
406- action : "stop"
414+ action : "stop" ,
415+ skipFollowUp : true
407416 } ) ;
408417 } ) ;
409418 audioVolUp = document . getElementById ( 'sepiaFW-audio-ctrls-volup' ) ;
410419 $ ( audioVolUp ) . off ( ) . on ( 'click' , function ( ) {
411- playerSetVolume ( playerGetVolume ( ) + 1.0 ) ;
420+ //playerSetVolume(playerGetVolume() + 1.0);
421+ SepiaFW . client . controls . volume ( {
422+ action : "up"
423+ } ) ;
412424 } ) ;
413425 audioVolDown = document . getElementById ( 'sepiaFW-audio-ctrls-voldown' ) ;
414426 $ ( audioVolDown ) . off ( ) . on ( 'click' , function ( ) {
415- playerSetVolume ( playerGetVolume ( ) - 1.0 ) ;
427+ //playerSetVolume(playerGetVolume() - 1.0);
428+ SepiaFW . client . controls . volume ( {
429+ action : "down"
430+ } ) ;
416431 } ) ;
417432 audioVol = document . getElementById ( 'sepiaFW-audio-ctrls-vol' ) ;
418433 if ( audioVol ) audioVol . textContent = Math . round ( player . volume * 10.0 ) ;
@@ -425,7 +440,8 @@ function sepiaFW_build_audio(){
425440 //TODO: is this still up-to-date?
426441 return ( ! SepiaFW . ui . isStandaloneWebApp && ( SepiaFW . ui . isMobile || SepiaFW . ui . isSafari ) && doInitAudio ) ;
427442 }
428- AudioPlayer . initAudio = function ( continueCallback ) {
443+ AudioPlayer . initAudio = function ( continueCallback , noopOrContinueCallback ) {
444+ if ( noopOrContinueCallback && ! continueCallback ) continueCallback = noopOrContinueCallback ;
429445 //workaround for mobile devices to activate audio by scripts
430446 if ( AudioPlayer . requiresInit ( ) ) {
431447 SepiaFW . debug . info ( 'Audio - trying to initialize players' ) ;
@@ -451,6 +467,7 @@ function sepiaFW_build_audio(){
451467 return true ;
452468
453469 } else {
470+ if ( noopOrContinueCallback ) noopOrContinueCallback ( ) ;
454471 return false ;
455472 }
456473 }
@@ -726,7 +743,7 @@ function sepiaFW_build_audio(){
726743 var setVol = getValidVolume ( newVol ) / 10.0 ;
727744 player . volume = setVol ;
728745 orgVolume = setVol ;
729- $ ( '#sepiaFW-audio-ctrls-vol' ) . html ( Math . floor ( setVol * 10.0 ) ) ;
746+ $ ( '#sepiaFW-audio-ctrls-vol' ) . text ( Math . floor ( setVol * 10.0 ) ) ;
730747 SepiaFW . debug . info ( 'AUDIO: volume set (and stored) to ' + setVol ) ;
731748 broadcastPlayerVolumeSet ( ) ;
732749 }
@@ -750,7 +767,7 @@ function sepiaFW_build_audio(){
750767 if ( mainAudioIsOnHold || ( SepiaFW . speech . isSpeakingOrListening ( ) ) ) {
751768 var setVol = getValidVolume ( newVol ) / 10.0 ;
752769 orgVolume = setVol ;
753- $ ( '#sepiaFW-audio-ctrls-vol' ) . html ( Math . floor ( setVol * 10.0 ) ) ;
770+ $ ( '#sepiaFW-audio-ctrls-vol' ) . text ( Math . floor ( setVol * 10.0 ) ) ;
754771 SepiaFW . debug . info ( 'AUDIO: unfaded volume set to ' + setVol ) ;
755772 broadcastPlayerVolumeSet ( ) ;
756773 } else {
@@ -765,7 +782,7 @@ function sepiaFW_build_audio(){
765782 var lastStream = SepiaFW . audio . getLastAudioStream ( ) ;
766783 var lastStreamTitle = ( lastStream ) ? SepiaFW . audio . getLastAudioStreamTitle ( ) : "" ;
767784 SepiaFW . audio . playURL ( lastStream , '' ) ; //<-- potentially looses callBack info here, but since this is stopped
768- SepiaFW . audio . setPlayerTitle ( lastStreamTitle , '' ) ;
785+ SepiaFW . audio . setPlayerTitle ( lastStreamTitle , "stream" ) ;
769786 }
770787 SepiaFW . debug . info ( 'AUDIO: fadeToOriginal - restore vol=' + orgVolume ) ;
771788 $ ( player ) . stop ( ) ; //note: this is an animation stop
@@ -785,14 +802,19 @@ function sepiaFW_build_audio(){
785802 a . protocol == loc . protocol ;
786803 }
787804
788- //set title of player
789- AudioPlayer . setPlayerTitle = function ( newTitle , audioPlayer ) {
790- if ( ! audioPlayer ) audioPlayer = player ;
791- audioPlayer . title = newTitle ;
792- if ( audioTitle ) audioTitle . textContent = newTitle || "SEPIA Audio Player" ;
793- if ( audioPlayer == player ) {
805+ //set title of player - NOTE: compared to most functions below this is not limited to "stream" player
806+ AudioPlayer . setPlayerTitle = function ( newTitle , playerTag ) {
807+ //playerTag: stream, embedded-media- player, android-intent
808+ if ( playerTag == undefined ) playerTag = "stream" ;
809+ if ( playerTag == "stream" || playerTag == player ) {
810+ //Stream player
794811 lastAudioStreamTitle = newTitle ;
812+ player . title = newTitle ;
813+ currentAudioTitleBelongsToStreamPlayer = true ;
814+ } else {
815+ currentAudioTitleBelongsToStreamPlayer = false ;
795816 }
817+ if ( audioTitle ) audioTitle . textContent = newTitle || "SEPIA Audio Player" ;
796818 }
797819
798820 //get the stream last played
@@ -809,7 +831,7 @@ function sepiaFW_build_audio(){
809831 var lastStreamTitle = ( lastStream ) ? AudioPlayer . getLastAudioStreamTitle ( ) : "" ;
810832 if ( lastStream ) {
811833 AudioPlayer . playURL ( lastStream , player ) ;
812- AudioPlayer . setPlayerTitle ( lastStreamTitle ) ;
834+ AudioPlayer . setPlayerTitle ( lastStreamTitle , "stream" ) ;
813835 return true ;
814836 } else {
815837 return false ;
0 commit comments