diff --git a/index.html b/index.html
index 941907176..ccee32ee4 100644
--- a/index.html
+++ b/index.html
@@ -19,9 +19,9 @@
-
Wallet ID: {{$root.wallet.id}}
+
{{$root.wallet.id}}
Wallet: {{$root.wallet.name}} <{{$root.wallet.id}}>
- [{{$root.wallet.requiredCopayers}}/{{$root.wallet.totalCopayers}}]
+ ({{$root.wallet.requiredCopayers}}-of-{{$root.wallet.totalCopayers}})
@@ -198,7 +198,7 @@
Wallet name (optional)
-
+
diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js
index a02a99ff2..45883f719 100644
--- a/js/services/controllerUtils.js
+++ b/js/services/controllerUtils.js
@@ -17,6 +17,8 @@ angular.module('copay.controllerUtils')
$rootScope.wallet = null;
delete $rootScope['wallet'];
$rootScope.totalBalance = 0;
+ video.close();
+ $rootScope.videoSrc = {};
$location.path('signin');
};
@@ -38,6 +40,7 @@ angular.module('copay.controllerUtils')
root.startNetwork = function(w) {
var handlePeerVideo = function(err, peerID, url) {
if (err) {
+ delete $rootScope.videoSrc[peerID];
return;
}
$rootScope.videoSrc[peerID] = encodeURI(url);
diff --git a/js/services/video.js b/js/services/video.js
index f5dbb74d3..fde16d506 100644
--- a/js/services/video.js
+++ b/js/services/video.js
@@ -6,12 +6,12 @@ var Video = function() {
navigator.mozGetUserMedia;
this.mediaConnections = {};
+ this.localStream = null;
};
Video.prototype.setOwnPeer = function(peer, wallet, cb) {
var self = this;
-
navigator.getUserMedia({
audio: true,
video: true
@@ -21,7 +21,6 @@ Video.prototype.setOwnPeer = function(peer, wallet, cb) {
var online = wallet.getOnlinePeerIDs();
for (var i = 0; i < online.length; i++) {
var o = online[i];
- var mc = self.mediaConnections[o];
if (o !== peer.id) {
self.callPeer(o, cb);
}
@@ -38,7 +37,6 @@ Video.prototype.setOwnPeer = function(peer, wallet, cb) {
} else {
mediaConnection.answer();
}
- self.mediaConnections[mediaConnection.peer] = mediaConnection;
self._addCall(mediaConnection, cb);
});
this.peer = peer;
@@ -60,9 +58,26 @@ Video.prototype._addCall = function(mediaConnection, cb) {
});
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());