add confvideo directive

This commit is contained in:
Manuel Araoz 2014-05-07 19:04:36 -03:00
commit 82a07d2c10
4 changed files with 97 additions and 68 deletions

View file

@ -3,17 +3,26 @@
angular.module('copay.controllerUtils')
.factory('controllerUtils', function($rootScope, $sce, $location, Socket, video) {
var root = {};
$rootScope.videoSrc = {};
$rootScope.videoInfo = {};
$rootScope.loading = false;
$rootScope.getVideoURL = function(copayer) {
var encoded = $rootScope.videoSrc[copayer];
if (!encoded) return;
var vi = $rootScope.videoInfo[copayer]
if (!vi) return;
var encoded = vi.url;
var url = decodeURI(encoded);
var trusted = $sce.trustAsResourceUrl(url);
return trusted;
};
$rootScope.getVideoMutedStatus = function(copayer) {
var vi = $rootScope.videoInfo[copayer]
if (!vi) {
return;
}
return vi.muted;
};
$rootScope.getWalletDisplay = function() {
var w = $rootScope.wallet;
return w && (w.name || w.id);
@ -24,7 +33,7 @@ angular.module('copay.controllerUtils')
delete $rootScope['wallet'];
$rootScope.totalBalance = 0;
video.close();
$rootScope.videoSrc = {};
$rootScope.videoInfo = {};
$location.path('signin');
};
@ -41,10 +50,13 @@ angular.module('copay.controllerUtils')
root.startNetwork = function(w) {
var handlePeerVideo = function(err, peerID, url) {
if (err) {
delete $rootScope.videoSrc[peerID];
delete $rootScope.videoInfo[peerID];
return;
}
$rootScope.videoSrc[peerID] = encodeURI(url);
$rootScope.videoInfo[peerID] = {
url: encodeURI(url),
muted: peerID === w.network.peerId
};
$rootScope.$digest();
};
w.on('badMessage', function(peerId) {