diff --git a/static/js/directives/screenshare.js b/static/js/directives/screenshare.js index 0e6c0726..58e73dd7 100644 --- a/static/js/directives/screenshare.js +++ b/static/js/directives/screenshare.js @@ -95,9 +95,11 @@ define(['jquery', 'underscore', 'text!partials/screenshare.html', 'text!partials mediaStream.webrtc.doSubscribeScreenshare(from, token, { created: function(peerscreenshare) { peerscreenshare.e.on("remoteStreamAdded", function(event, stream) { - $scope.$apply(function(scope) { - scope.addRemoteStream(stream, peerscreenshare); - }); + if (stream) { + $scope.$apply(function(scope) { + scope.addRemoteStream(stream, peerscreenshare); + }); + } }); peerscreenshare.e.on("remoteStreamRemoved", function(event, stream) { safeApply($scope, function(scope) { diff --git a/static/js/services/videowaiter.js b/static/js/services/videowaiter.js index 6a57af9b..a57cb79e 100644 --- a/static/js/services/videowaiter.js +++ b/static/js/services/videowaiter.js @@ -36,7 +36,7 @@ define(["underscore"], function(_) { } return; } - var videoTracks = stream.getVideoTracks(); + var videoTracks = stream && stream.getVideoTracks() || []; //console.log("wait for video", videoTracks.length, video.currentTime, video.videoHeight, video); if (videoTracks.length === 0 && this.count >= 10) { cb(false, video, stream);