Browse Source

Use "safeApply" when handling webrtc done/stop events.

pull/284/head
Joachim Bauch 9 years ago
parent
commit
14764dd17f
  1. 34
      static/js/directives/audiovideo.js

34
static/js/directives/audiovideo.js

@ -291,40 +291,40 @@ define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/ @@ -291,40 +291,40 @@ define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/
mediaStream.webrtc.e.on("done stop", function(event) {
$scope.$apply(function() {
if (!$scope.isActive) {
safeApply($scope, function(scope) {
if (!scope.isActive) {
return;
}
$scope.hasUsermedia = false;
$scope.isActive = false;
$scope.peersTalking = {};
scope.hasUsermedia = false;
scope.isActive = false;
scope.peersTalking = {};
if (BigScreen.enabled) {
BigScreen.exit();
}
var removeVideos = function() {
if ($scope.isActive) {
if (scope.isActive) {
return;
}
$scope.localVideo.src = '';
$scope.miniVideo.src = '';
$($scope.remoteVideos).children(".remoteVideo").remove();
scope.localVideo.src = '';
scope.miniVideo.src = '';
$(scope.remoteVideos).children(".remoteVideo").remove();
};
if (event.type === "stop") {
removeVideos();
} else {
$timeout(removeVideos, 1500);
}
$($scope.mini).removeClass("visible");
$scope.localVideos.style.opacity = 1;
$scope.localVideo.style.opacity = 0;
$scope.remoteVideos.style.opacity = 0;
$(scope.mini).removeClass("visible");
scope.localVideos.style.opacity = 1;
scope.localVideo.style.opacity = 0;
scope.remoteVideos.style.opacity = 0;
$element.removeClass('active');
_.each(streams, function(scope, k) {
scope.$destroy();
_.each(streams, function(streamscope, k) {
streamscope.$destroy();
delete streams[k];
});
$scope.rendererName = $scope.defaultRendererName;
$scope.haveStreams = false;
scope.rendererName = scope.defaultRendererName;
scope.haveStreams = false;
});
});

Loading…
Cancel
Save