diff --git a/ffw/NavigationRPC.js b/ffw/NavigationRPC.js index df166cd68..181b809e5 100644 --- a/ffw/NavigationRPC.js +++ b/ffw/NavigationRPC.js @@ -46,6 +46,16 @@ FFW.Navigation = FFW.RPCObserver.create( * Error codes will be injected into response. */ errorResponsePull: {}, + /** + * Contains pointer to currently active popup window with start Audio + * streaming in the model or null if does not exists + */ + startAudioStreamingPopup: null, + /** + * Contains pointer to currently active popup window with start Video + * streaming in the model or null if does not exists + */ + startVideoStreamingPopup: null, /** * access to basic RPC functionality */ @@ -280,7 +290,11 @@ FFW.Navigation = FFW.RPCObserver.create( case 'Navigation.StartAudioStream': { var text = 'Would you like to start Audio stream?'; - SDL.PopUp.create().appendTo('body').popupActivate( + if (this.startAudioStreamingPopup && this.startAudioStreamingPopup.active) { + this.startAudioStreamingPopup.deactivate(); + } + + this.startAudioStreamingPopup = SDL.PopUp.create().appendTo('body').popupActivate( text, function(result) { if (result) { FFW.Navigation.sendNavigationResult( @@ -308,6 +322,10 @@ FFW.Navigation = FFW.RPCObserver.create( SDL.SDLController.getApplicationModel( request.params.appID ).navigationAudioStream = null; + if (this.startAudioStreamingPopup && this.startAudioStreamingPopup.active) { + this.startAudioStreamingPopup.deactivate(); + this.set('startAudioStreamingPopup', null); + } this.sendNavigationResult( SDL.SDLModel.data.resultCode.SUCCESS, request.id, @@ -355,7 +373,11 @@ FFW.Navigation = FFW.RPCObserver.create( case 'Navigation.StartStream': { var text = 'Would you like to start Video stream?'; - SDL.PopUp.create().appendTo('body').popupActivate( + if (this.startVideoStreamingPopup && this.startVideoStreamingPopup.active) { + this.startVideoStreamingPopup.deactivate(); + } + + this.startVideoStreamingPopup = SDL.PopUp.create().appendTo('body').popupActivate( text, function(result) { if (result) { SDL.SDLController.getApplicationModel(request.params.appID) @@ -378,6 +400,7 @@ FFW.Navigation = FFW.RPCObserver.create( SDL.SDLController.getApplicationModel( request.params.appID ).navigationStream = request.params.url; + break; } case 'Navigation.StopStream': @@ -385,6 +408,10 @@ FFW.Navigation = FFW.RPCObserver.create( SDL.SDLController.getApplicationModel( request.params.appID ).navigationStream = null; + if (this.startVideoStreamingPopup && this.startVideoStreamingPopup.active) { + this.startVideoStreamingPopup.deactivate(); + this.set('startVideoStreamingPopup', null); + } this.sendNavigationResult( SDL.SDLModel.data.resultCode.SUCCESS, request.id,