FS-8400 [verto_communicator] Added Camera and microphone preview after the splash screen.

This commit is contained in:
Jaon EarlWolf
2015-11-06 15:50:51 -03:00
parent 0d6e17b65a
commit 522547f84e
10 changed files with 384 additions and 16 deletions

View File

@@ -7,9 +7,9 @@
'$http', '$location', 'toastr', 'verto', 'storage', 'CallHistory', 'eventQueue',
function($rootScope, $scope, $http, $location, toastr, verto, storage, CallHistory, eventQueue) {
console.debug('Executing DialPadController.');
eventQueue.process();
$scope.call_history = CallHistory.all();
$scope.history_control = CallHistory.all_control();
$scope.has_history = Object.keys($scope.call_history).length;
@@ -55,6 +55,10 @@
$rootScope.dialpadNumber = number;
};
$scope.preview = function() {
$location.path('/preview');
};
$rootScope.transfer = function() {
if (!$rootScope.dialpadNumber) {
return false;

View File

@@ -52,7 +52,10 @@
storage.data.email = verto.data.email;
storage.data.login = verto.data.login;
storage.data.password = verto.data.password;
if (redirect) {
if (redirect && storage.data.preview) {
$location.path('/preview');
}
else if (redirect) {
$location.path('/dialpad');
}
}

View File

@@ -0,0 +1,142 @@
(function() {
'use strict';
angular
.module('vertoControllers')
.controller('PreviewController', ['$rootScope', '$scope',
'$http', '$location', '$modal', '$timeout', 'toastr', 'verto', 'storage', 'prompt', 'Fullscreen',
function($rootScope, $scope, $http, $location, $modal, $timeout, toastr,
verto, storage, prompt, Fullscreen) {
$scope.storage = storage;
console.debug('Executing PreviewController.');
var localVideo = document.getElementById('videopreview');
var volumes = document.querySelector('#mic-meter .volumes').children;
$scope.localVideo = function() {
var constraints = {
mirrored: true,
audio: {
optional: [{ sourceId: storage.data.selectedAudio }]
}
};
if (storage.data.selectedVideo !== 'none') {
constraints.video = {
optional: [{ sourceId: storage.data.selectedVideo }]
};
}
navigator.getUserMedia(constraints, handleMedia, function(err, data) {
});
};
var audioContext = new AudioContext();
var mediaStreamSource = null;
var meter;
var streamObj = {};
function handleMedia(stream) {
streamObj.stop ? streamObj.stop() : streamObj.active = false;
streamObj = stream;
localVideo.src = window.URL.createObjectURL(stream);
mediaStreamSource = audioContext.createMediaStreamSource(stream);
meter = createAudioMeter(audioContext);
mediaStreamSource.connect(meter);
renderMic();
}
function renderMic() {
// meter.volume;
var n = Math.round(meter.volume * 25);
for(var i = volumes.length -1, j = 0; i >= 0; i--, j++) {
var el = angular.element(volumes[j]);
if (i >= n) el.removeClass('active');
else el.addClass('active');
}
if(!verto.data.call) {
window.requestAnimationFrame(renderMic);
}
}
/**
* TODO: useless?
*/
$scope.refreshDeviceList = function() {
return verto.refreshDevices();
};
$scope.videoCall = function() {
prompt({
title: 'Would you like to activate video for this call?',
message: 'Video will be active during the next calls.'
}).then(function() {
storage.data.videoCall = true;
$scope.callTemplate = 'partials/video_call.html';
});
};
$scope.cbMuteVideo = function(event, data) {
storage.data.mutedVideo = !storage.data.mutedVideo;
}
$scope.cbMuteMic = function(event, data) {
storage.data.mutedMic = !storage.data.mutedMic;
}
$scope.confChangeVideoLayout = function(layout) {
verto.data.conf.setVideoLayout(layout);
};
$scope.endPreview = function() {
localVideo.src = null;
meter.shutdown();
meter.onaudioprocess = null;
streamObj.stop();
$location.path('/dialpad');
storage.data.preview = false;
};
$scope.screenshare = function() {
if(verto.data.shareCall) {
verto.screenshareHangup();
return false;
}
verto.screenshare(storage.data.called_number);
};
$scope.call = function() {
if($rootScope.dialpadNumber) {
localVideo.src = null;
meter.shutdown();
meter.onaudioprocess = null;
streamObj.stop();
}
$rootScope.call($rootScope.dialpadNumber);
};
$scope.muteMic = verto.muteMic;
$scope.muteVideo = verto.muteVideo;
$rootScope.$on('ScreenShareExtensionStatus', function(event, error) {
var pluginUrl = 'https://chrome.google.com/webstore/detail/screen-capturing/ajhifddimkapgcifgcodmmfdlknahffk';
switch(error) {
case 'permission-denied':
toastr.info('Please allow the plugin in order to use Screen Share', 'Error'); break;
case 'not-installed':
toastr.warning('Please <a target="_blank" class="install" href="'+ pluginUrl +'">install</a> the plugin in order to use Screen Share', 'Warning', { allowHtml: true }); break;
case 'installed-disabled':
toastr.info('Please enable the plugin in order to use Screen Share', 'Error'); break;
// case 'not-chrome'
// toastr.info('Chrome', 'Error');
}
});
$scope.localVideo();
}
]);
})();

View File

@@ -3,10 +3,10 @@
angular
.module('vertoControllers')
.controller('SplashScreenController', ['$scope', '$rootScope', '$location', '$timeout', 'splashscreen', 'prompt', 'verto',
function($scope, $rootScope, $location, $timeout, splashscreen, prompt, verto) {
.controller('SplashScreenController', ['$scope', '$rootScope', '$location', '$timeout', 'storage', 'splashscreen', 'prompt', 'verto',
function($scope, $rootScope, $location, $timeout, storage, splashscreen, prompt, verto) {
console.debug('Executing SplashScreenController.');
$scope.progress_percentage = splashscreen.progress_percentage;
$scope.message = '';
$scope.interrupt_next = false;
@@ -18,26 +18,26 @@
link = activity;
}
}
$location.path(link);
}
var checkProgressState = function(current_progress, status, promise, activity, soft, interrupt, message) {
$scope.progress_percentage = splashscreen.calculate(current_progress);
$scope.progress_percentage = splashscreen.calculate(current_progress);
$scope.message = message;
if(interrupt && status == 'error') {
$scope.errors.push(message);
if(!soft) {
redirectTo('', activity);
redirectTo('', activity);
return;
} else {
message = message + '. Continue?';
message = message + '. Continue?';
};
if(!confirm(message)) {
$scope.interrupt_next = true;
};
$scope.interrupt_next = true;
};
};
if($scope.interrupt_next) {
@@ -48,7 +48,7 @@
return true;
};
$rootScope.$on('progress.next', function(ev, current_progress, status, promise, activity, soft, interrupt, message) {
$timeout(function() {
if(promise) {
@@ -62,11 +62,11 @@
return;
}
if(!checkProgressState(current_progress, status, promise, activity, soft, interrupt, message)) {
return;
}
splashscreen.next();
}, 400);
});
@@ -74,7 +74,12 @@
$rootScope.$on('progress.complete', function(ev, current_progress) {
$scope.message = 'Complete';
if(verto.data.connected) {
redirectTo('/dialpad');
if (storage.data.preview) {
$location.path('/preview');
}
else {
$location.path('/dialpad');
}
} else {
redirectTo('/login');
$location.path('/login');