video logout handling
This commit is contained in:
parent
274e39e2cd
commit
c89f9528c8
2 changed files with 22 additions and 4 deletions
|
|
@ -17,6 +17,8 @@ angular.module('copay.controllerUtils')
|
||||||
$rootScope.wallet = null;
|
$rootScope.wallet = null;
|
||||||
delete $rootScope['wallet'];
|
delete $rootScope['wallet'];
|
||||||
$rootScope.totalBalance = 0;
|
$rootScope.totalBalance = 0;
|
||||||
|
video.close();
|
||||||
|
$rootScope.videoSrc = {};
|
||||||
$location.path('signin');
|
$location.path('signin');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -38,6 +40,7 @@ angular.module('copay.controllerUtils')
|
||||||
root.startNetwork = function(w) {
|
root.startNetwork = function(w) {
|
||||||
var handlePeerVideo = function(err, peerID, url) {
|
var handlePeerVideo = function(err, peerID, url) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
delete $rootScope.videoSrc[peerID];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$rootScope.videoSrc[peerID] = encodeURI(url);
|
$rootScope.videoSrc[peerID] = encodeURI(url);
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@ var Video = function() {
|
||||||
navigator.mozGetUserMedia;
|
navigator.mozGetUserMedia;
|
||||||
|
|
||||||
this.mediaConnections = {};
|
this.mediaConnections = {};
|
||||||
|
this.localStream = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
Video.prototype.setOwnPeer = function(peer, wallet, cb) {
|
Video.prototype.setOwnPeer = function(peer, wallet, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
|
||||||
navigator.getUserMedia({
|
navigator.getUserMedia({
|
||||||
audio: true,
|
audio: true,
|
||||||
video: true
|
video: true
|
||||||
|
|
@ -21,7 +21,6 @@ Video.prototype.setOwnPeer = function(peer, wallet, cb) {
|
||||||
var online = wallet.getOnlinePeerIDs();
|
var online = wallet.getOnlinePeerIDs();
|
||||||
for (var i = 0; i < online.length; i++) {
|
for (var i = 0; i < online.length; i++) {
|
||||||
var o = online[i];
|
var o = online[i];
|
||||||
var mc = self.mediaConnections[o];
|
|
||||||
if (o !== peer.id) {
|
if (o !== peer.id) {
|
||||||
self.callPeer(o, cb);
|
self.callPeer(o, cb);
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +37,6 @@ Video.prototype.setOwnPeer = function(peer, wallet, cb) {
|
||||||
} else {
|
} else {
|
||||||
mediaConnection.answer();
|
mediaConnection.answer();
|
||||||
}
|
}
|
||||||
self.mediaConnections[mediaConnection.peer] = mediaConnection;
|
|
||||||
self._addCall(mediaConnection, cb);
|
self._addCall(mediaConnection, cb);
|
||||||
});
|
});
|
||||||
this.peer = peer;
|
this.peer = peer;
|
||||||
|
|
@ -60,9 +58,26 @@ Video.prototype._addCall = function(mediaConnection, cb) {
|
||||||
});
|
});
|
||||||
|
|
||||||
mediaConnection.on('close', function() {
|
mediaConnection.on('close', function() {
|
||||||
|
console.log('Media connection closed with ' + peerID);
|
||||||
|
cb(true, peerID, null); // ask to stop video streaming in UI
|
||||||
});
|
});
|
||||||
mediaConnection.on('error', function() {
|
mediaConnection.on('error', function(e) {
|
||||||
|
console.log('Media connection error with ' + peerID);
|
||||||
|
cb(e, peerID, null);
|
||||||
});
|
});
|
||||||
|
this.mediaConnections[peerID] = mediaConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Video.prototype.close = function() {
|
||||||
|
this.localStream.stop();
|
||||||
|
this.localStream.mozSrcObject = null;
|
||||||
|
this.localStream.src = "";
|
||||||
|
this.localStream.src = null;
|
||||||
|
this.localStream = null;
|
||||||
|
for (var i = 0; this.mediaConnections.length; i++) {
|
||||||
|
this.mediaConnections[i].close();
|
||||||
|
}
|
||||||
|
this.mediaConnections = {};
|
||||||
|
};
|
||||||
|
|
||||||
angular.module('copay.video').value('video', new Video());
|
angular.module('copay.video').value('video', new Video());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue