diff --git a/static/js/directives/screenshare.js b/static/js/directives/screenshare.js index 58e73dd7f..b868cb899 100644 --- a/static/js/directives/screenshare.js +++ b/static/js/directives/screenshare.js @@ -172,6 +172,7 @@ define(['jquery', 'underscore', 'text!partials/screenshare.html', 'text!partials } $scope.layout.screenshare = true; + screensharing.globalNotify().screensharingStart(); screensharing.getScreen().then(function(options) { if (options) { $scope.startScreenshare(options); @@ -307,6 +308,8 @@ define(['jquery', 'underscore', 'text!partials/screenshare.html', 'text!partials $scope.layout.screenshare = false; } + screensharing.globalNotify().screensharingStop(); + }; $scope.toggleFullscreen = function(elem) { diff --git a/static/js/services/screensharing.js b/static/js/services/screensharing.js index 2cc5c54f0..67d57d074 100644 --- a/static/js/services/screensharing.js +++ b/static/js/services/screensharing.js @@ -32,6 +32,9 @@ define(['underscore', 'text!partials/screensharedialogff.html', 'webrtc.adapter' }; }]; + var GLOBAL_SCREENSHARING_START_EVENT = new Event('webrtcStartScreensharing'); + var GLOBAL_SCREENSHARING_STOP_EVENT = new Event('webrtcStopScreensharing'); + // screensharing return ["$window", "$q", "$timeout", "chromeExtension", "dialogs", "$templateCache", function($window, $q, $timeout, chromeExtension, dialogs, $templateCache) { @@ -45,6 +48,17 @@ define(['underscore', 'text!partials/screensharedialogff.html', 'webrtc.adapter' }, this)); }; + Screensharing.prototype.globalNotify = function() { + return { + screensharingStart: function() { + $window.dispatchEvent(GLOBAL_SCREENSHARING_START_EVENT); + }, + screensharingStop: function() { + $window.dispatchEvent(GLOBAL_SCREENSHARING_STOP_EVENT); + } + }; + }; + Screensharing.prototype.initialize = function() { // Check if we can do screensharing.