2013-12-16 11:22:23 +00:00
|
|
|
/* jshint -W117 */
|
|
|
|
/* application specific logic */
|
|
|
|
var connection = null;
|
|
|
|
var focus = null;
|
2014-02-27 07:19:06 +00:00
|
|
|
var activecall = null;
|
|
|
|
var RTC = null;
|
2013-12-16 11:22:23 +00:00
|
|
|
var nickname = null;
|
|
|
|
var sharedKey = '';
|
|
|
|
var roomUrl = null;
|
2014-01-09 20:44:37 +00:00
|
|
|
var ssrc2jid = {};
|
2014-03-26 18:06:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether ssrc is camera video or desktop stream.
|
|
|
|
* FIXME: remove those maps
|
|
|
|
*/
|
|
|
|
var ssrc2videoType = {};
|
|
|
|
var videoSrcToSsrc = {};
|
|
|
|
|
2014-01-15 09:29:27 +00:00
|
|
|
var localVideoSrc = null;
|
2014-03-17 09:02:40 +00:00
|
|
|
var flipXLocalVideo = true;
|
2014-03-26 10:33:46 +00:00
|
|
|
var isFullScreen = false;
|
|
|
|
var toolbarTimeout = null;
|
|
|
|
var currentVideoWidth = null;
|
|
|
|
var currentVideoHeight = null;
|
2014-03-26 18:06:34 +00:00
|
|
|
/**
|
|
|
|
* Method used to calculate large video size.
|
|
|
|
* @type {function()}
|
|
|
|
*/
|
|
|
|
var getVideoSize;
|
2014-03-28 09:37:14 +00:00
|
|
|
/**
|
|
|
|
* Method used to get large video position.
|
|
|
|
* @type {function()}
|
|
|
|
*/
|
|
|
|
var getVideoPosition;
|
2013-12-16 11:22:23 +00:00
|
|
|
|
2014-01-11 16:16:46 +00:00
|
|
|
/* window.onbeforeunload = closePageWarning; */
|
2013-12-20 14:19:17 +00:00
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
function init() {
|
|
|
|
RTC = setupRTC();
|
|
|
|
if (RTC === null) {
|
2013-12-30 08:23:23 +00:00
|
|
|
window.location.href = 'webrtcrequired.html';
|
2013-12-16 11:22:23 +00:00
|
|
|
return;
|
2014-03-01 07:39:39 +00:00
|
|
|
} else if (RTC.browser !== 'chrome') {
|
2013-12-30 08:23:23 +00:00
|
|
|
window.location.href = 'chromeonly.html';
|
2013-12-16 11:22:23 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
|
2014-02-11 14:05:17 +00:00
|
|
|
|
|
|
|
if (nickname) {
|
|
|
|
connection.emuc.addDisplayNameToPresence(nickname);
|
|
|
|
}
|
|
|
|
|
2013-12-30 08:23:23 +00:00
|
|
|
if (connection.disco) {
|
|
|
|
// for chrome, add multistream cap
|
|
|
|
}
|
2013-12-16 11:22:23 +00:00
|
|
|
connection.jingle.pc_constraints = RTC.pc_constraints;
|
2014-01-26 14:43:43 +00:00
|
|
|
if (config.useIPv6) {
|
|
|
|
// https://code.google.com/p/webrtc/issues/detail?id=2828
|
|
|
|
if (!connection.jingle.pc_constraints.optional) connection.jingle.pc_constraints.optional = [];
|
|
|
|
connection.jingle.pc_constraints.optional.push({googIPv6: true});
|
|
|
|
}
|
2013-12-16 11:22:23 +00:00
|
|
|
|
|
|
|
var jid = document.getElementById('jid').value || config.hosts.domain || window.location.hostname;
|
|
|
|
|
|
|
|
connection.connect(jid, document.getElementById('password').value, function (status) {
|
2014-03-01 07:39:39 +00:00
|
|
|
if (status === Strophe.Status.CONNECTED) {
|
2013-12-16 11:22:23 +00:00
|
|
|
console.log('connected');
|
2014-01-26 12:18:12 +00:00
|
|
|
if (config.useStunTurn) {
|
|
|
|
connection.jingle.getStunAndTurnCredentials();
|
|
|
|
}
|
2014-03-24 17:31:59 +00:00
|
|
|
obtainAudioAndVideoPermissions(function(){
|
|
|
|
getUserMediaWithConstraints( ['audio'], audioStreamReady,
|
|
|
|
function(error){
|
|
|
|
console.error('failed to obtain audio stream - stop', error);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
document.getElementById('connect').disabled = true;
|
|
|
|
} else {
|
|
|
|
console.log('status', status);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-03-24 17:31:59 +00:00
|
|
|
/**
|
2014-03-25 09:30:28 +00:00
|
|
|
* HTTPS only:
|
2014-03-24 17:31:59 +00:00
|
|
|
* We first ask for audio and video combined stream in order to get permissions and not to ask twice.
|
|
|
|
* Then we dispose the stream and continue with separate audio, video streams(required for desktop sharing).
|
|
|
|
*/
|
|
|
|
function obtainAudioAndVideoPermissions(callback){
|
2014-03-25 09:30:28 +00:00
|
|
|
// This makes sense only on https sites otherwise we'll be asked for permissions every time
|
|
|
|
if(location.protocol !== 'https:') {
|
|
|
|
callback();
|
|
|
|
return;
|
|
|
|
}
|
2014-03-24 17:31:59 +00:00
|
|
|
// Get AV
|
|
|
|
getUserMediaWithConstraints(
|
|
|
|
['audio', 'video'],
|
|
|
|
function(avStream) {
|
|
|
|
avStream.stop();
|
|
|
|
callback();
|
|
|
|
},
|
|
|
|
function(error){
|
|
|
|
console.error('failed to obtain audio/video stream - stop', error);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-03-12 15:08:24 +00:00
|
|
|
function audioStreamReady(stream) {
|
|
|
|
|
|
|
|
change_local_audio(stream);
|
|
|
|
|
|
|
|
if(RTC.browser !== 'firefox') {
|
|
|
|
getUserMediaWithConstraints( ['video'], videoStreamReady, videoStreamFailed, config.resolution || '360' );
|
|
|
|
} else {
|
|
|
|
doJoin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function videoStreamReady(stream) {
|
|
|
|
|
2014-03-17 09:02:40 +00:00
|
|
|
change_local_video(stream, true);
|
2014-03-12 15:08:24 +00:00
|
|
|
|
|
|
|
doJoin();
|
|
|
|
}
|
|
|
|
|
|
|
|
function videoStreamFailed(error) {
|
|
|
|
|
|
|
|
console.warn("Failed to obtain video stream - continue anyway", error);
|
|
|
|
|
|
|
|
doJoin();
|
|
|
|
}
|
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
function doJoin() {
|
|
|
|
var roomnode = null;
|
|
|
|
var path = window.location.pathname;
|
|
|
|
var roomjid;
|
2014-01-10 21:06:20 +00:00
|
|
|
|
|
|
|
// determinde the room node from the url
|
|
|
|
// TODO: just the roomnode or the whole bare jid?
|
|
|
|
if (config.getroomnode && typeof config.getroomnode === 'function') {
|
|
|
|
// custom function might be responsible for doing the pushstate
|
|
|
|
roomnode = config.getroomnode(path);
|
2013-12-16 11:22:23 +00:00
|
|
|
} else {
|
2014-01-10 21:06:20 +00:00
|
|
|
/* fall back to default strategy
|
|
|
|
* this is making assumptions about how the URL->room mapping happens.
|
|
|
|
* It currently assumes deployment at root, with a rewrite like the
|
|
|
|
* following one (for nginx):
|
|
|
|
location ~ ^/([a-zA-Z0-9]+)$ {
|
|
|
|
rewrite ^/(.*)$ / break;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
if (path.length > 1) {
|
|
|
|
roomnode = path.substr(1).toLowerCase();
|
|
|
|
} else {
|
|
|
|
roomnode = Math.random().toString(36).substr(2, 20);
|
2014-02-26 15:19:39 +00:00
|
|
|
window.history.pushState('VideoChat',
|
|
|
|
'Room: ' + roomnode, window.location.pathname + roomnode);
|
2014-01-10 21:06:20 +00:00
|
|
|
}
|
2013-12-16 11:22:23 +00:00
|
|
|
}
|
2014-02-12 22:24:26 +00:00
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
roomjid = roomnode + '@' + config.hosts.muc;
|
|
|
|
|
|
|
|
if (config.useNicks) {
|
|
|
|
var nick = window.prompt('Your nickname (optional)');
|
|
|
|
if (nick) {
|
|
|
|
roomjid += '/' + nick;
|
|
|
|
} else {
|
|
|
|
roomjid += '/' + Strophe.getNodeFromJid(connection.jid);
|
|
|
|
}
|
|
|
|
} else {
|
2014-01-14 18:34:36 +00:00
|
|
|
roomjid += '/' + Strophe.getNodeFromJid(connection.jid).substr(0,8);
|
2013-12-16 11:22:23 +00:00
|
|
|
}
|
|
|
|
connection.emuc.doJoin(roomjid);
|
|
|
|
}
|
|
|
|
|
2014-03-12 15:08:24 +00:00
|
|
|
function change_local_audio(stream) {
|
|
|
|
connection.jingle.localAudio = stream;
|
|
|
|
RTC.attachMediaStream($('#localAudio'), stream);
|
|
|
|
document.getElementById('localAudio').autoplay = true;
|
|
|
|
document.getElementById('localAudio').volume = 0;
|
|
|
|
}
|
|
|
|
|
2014-03-17 09:02:40 +00:00
|
|
|
function change_local_video(stream, flipX) {
|
2014-03-12 15:08:24 +00:00
|
|
|
|
|
|
|
connection.jingle.localVideo = stream;
|
2013-12-16 11:22:23 +00:00
|
|
|
|
2014-03-17 09:02:40 +00:00
|
|
|
var localVideo = document.createElement('video');
|
|
|
|
localVideo.id = 'localVideo_'+stream.id;
|
|
|
|
localVideo.autoplay = true;
|
|
|
|
localVideo.volume = 0; // is it required if audio is separated ?
|
|
|
|
localVideo.oncontextmenu = function () { return false; };
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
var localVideoContainer = document.getElementById('localVideoWrapper');
|
2014-03-17 09:02:40 +00:00
|
|
|
localVideoContainer.appendChild(localVideo);
|
|
|
|
|
|
|
|
var localVideoSelector = $('#' + localVideo.id);
|
|
|
|
// Add click handler
|
|
|
|
localVideoSelector.click(function () { handleVideoThumbClicked(localVideo.src); } );
|
|
|
|
// Add stream ended handler
|
|
|
|
stream.onended = function () {
|
|
|
|
localVideoContainer.removeChild(localVideo);
|
|
|
|
checkChangeLargeVideo(localVideo.src);
|
|
|
|
};
|
|
|
|
// Flip video x axis if needed
|
|
|
|
flipXLocalVideo = flipX;
|
|
|
|
if(flipX) {
|
|
|
|
localVideoSelector.addClass("flipVideoX");
|
|
|
|
}
|
|
|
|
// Attach WebRTC stream
|
|
|
|
RTC.attachMediaStream(localVideoSelector, stream);
|
2014-02-12 22:24:26 +00:00
|
|
|
|
2014-03-17 09:02:40 +00:00
|
|
|
localVideoSrc = localVideo.src;
|
|
|
|
updateLargeVideo(localVideoSrc, 0);
|
2014-03-12 15:08:24 +00:00
|
|
|
}
|
2014-03-01 07:39:39 +00:00
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
$(document).bind('remotestreamadded.jingle', function (event, data, sid) {
|
2014-03-26 18:06:34 +00:00
|
|
|
function waitForRemoteVideo(selector, sid, ssrc) {
|
2014-03-12 15:08:24 +00:00
|
|
|
if(selector.removed) {
|
|
|
|
console.warn("media removed before had started", selector);
|
|
|
|
return;
|
|
|
|
}
|
2013-12-16 11:22:23 +00:00
|
|
|
var sess = connection.jingle.sessions[sid];
|
2014-03-01 07:39:39 +00:00
|
|
|
if (data.stream.id === 'mixedmslabel') return;
|
2014-03-26 18:06:34 +00:00
|
|
|
var videoTracks = data.stream.getVideoTracks();
|
2014-04-07 10:16:49 +00:00
|
|
|
// console.log("waiting..", videoTracks, selector[0]);
|
2014-03-31 12:49:33 +00:00
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
if (videoTracks.length === 0 || selector[0].currentTime > 0) {
|
|
|
|
RTC.attachMediaStream(selector, data.stream); // FIXME: why do i have to do this for FF?
|
2014-03-26 18:06:34 +00:00
|
|
|
|
|
|
|
// FIXME: add a class that will associate peer Jid, video.src, it's ssrc and video type
|
|
|
|
// in order to get rid of too many maps
|
|
|
|
if(ssrc) {
|
|
|
|
videoSrcToSsrc[sel.attr('src')] = ssrc;
|
|
|
|
} else {
|
|
|
|
console.warn("No ssrc given for video", sel);
|
|
|
|
}
|
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
$(document).trigger('callactive.jingle', [selector, sid]);
|
|
|
|
console.log('waitForremotevideo', sess.peerconnection.iceConnectionState, sess.peerconnection.signalingState);
|
|
|
|
} else {
|
2014-03-26 18:06:34 +00:00
|
|
|
setTimeout(function () { waitForRemoteVideo(selector, sid, ssrc); }, 250);
|
2013-12-16 11:22:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
var sess = connection.jingle.sessions[sid];
|
2014-01-09 20:44:37 +00:00
|
|
|
|
2014-03-26 18:06:34 +00:00
|
|
|
var thessrc;
|
2014-01-09 20:44:37 +00:00
|
|
|
// look up an associated JID for a stream id
|
2014-03-01 07:39:39 +00:00
|
|
|
if (data.stream.id.indexOf('mixedmslabel') === -1) {
|
2014-01-09 20:44:37 +00:00
|
|
|
var ssrclines = SDPUtil.find_lines(sess.peerconnection.remoteDescription.sdp, 'a=ssrc');
|
|
|
|
ssrclines = ssrclines.filter(function (line) {
|
2014-03-01 07:39:39 +00:00
|
|
|
return line.indexOf('mslabel:' + data.stream.label) !== -1;
|
2014-01-11 16:16:46 +00:00
|
|
|
});
|
2014-01-09 20:44:37 +00:00
|
|
|
if (ssrclines.length) {
|
|
|
|
thessrc = ssrclines[0].substring(7).split(' ')[0];
|
|
|
|
// ok to overwrite the one from focus? might save work in colibri.js
|
|
|
|
console.log('associated jid', ssrc2jid[thessrc], data.peerjid);
|
|
|
|
if (ssrc2jid[thessrc]) {
|
|
|
|
data.peerjid = ssrc2jid[thessrc];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-11 18:57:41 +00:00
|
|
|
var container;
|
|
|
|
var remotes = document.getElementById('remoteVideos');
|
2014-01-24 10:24:18 +00:00
|
|
|
|
2013-12-30 08:23:23 +00:00
|
|
|
if (data.peerjid) {
|
2014-02-26 15:19:39 +00:00
|
|
|
container = document.getElementById(
|
|
|
|
'participant_' + Strophe.getResourceFromJid(data.peerjid));
|
2014-01-11 18:57:41 +00:00
|
|
|
if (!container) {
|
2014-03-27 09:30:53 +00:00
|
|
|
console.error('no container for', data.peerjid);
|
2014-01-11 18:57:41 +00:00
|
|
|
} else {
|
|
|
|
//console.log('found container for', data.peerjid);
|
|
|
|
}
|
|
|
|
} else {
|
2014-03-01 07:39:39 +00:00
|
|
|
if (data.stream.id !== 'mixedmslabel') {
|
2014-03-17 15:43:06 +00:00
|
|
|
console.error('can not associate stream', data.stream.id, 'with a participant');
|
|
|
|
// We don't want to add it here since it will cause troubles
|
|
|
|
return;
|
2014-01-11 18:57:41 +00:00
|
|
|
}
|
|
|
|
// FIXME: for the mixed ms we dont need a video -- currently
|
|
|
|
container = document.createElement('span');
|
|
|
|
container.className = 'videocontainer';
|
|
|
|
remotes.appendChild(container);
|
2014-02-18 19:11:27 +00:00
|
|
|
Util.playSoundNotification('userJoined');
|
2013-12-30 08:23:23 +00:00
|
|
|
}
|
2014-03-12 15:08:24 +00:00
|
|
|
|
|
|
|
var isVideo = data.stream.getVideoTracks().length > 0;
|
|
|
|
var vid = isVideo ? document.createElement('video') : document.createElement('audio');
|
|
|
|
var id = (isVideo ? 'remoteVideo_' : 'remoteAudio_') + sid + '_' + data.stream.id;
|
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
vid.id = id;
|
|
|
|
vid.autoplay = true;
|
|
|
|
vid.oncontextmenu = function () { return false; };
|
2014-03-26 10:33:46 +00:00
|
|
|
|
2014-01-11 18:57:41 +00:00
|
|
|
container.appendChild(vid);
|
2014-03-26 10:33:46 +00:00
|
|
|
|
2014-01-11 18:57:41 +00:00
|
|
|
// TODO: make mixedstream display:none via css?
|
2014-03-01 07:39:39 +00:00
|
|
|
if (id.indexOf('mixedmslabel') !== -1) {
|
2014-01-11 18:57:41 +00:00
|
|
|
container.id = 'mixedstream';
|
|
|
|
$(container).hide();
|
2013-12-23 16:49:29 +00:00
|
|
|
}
|
2014-01-24 10:24:18 +00:00
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
var sel = $('#' + id);
|
|
|
|
sel.hide();
|
|
|
|
RTC.attachMediaStream(sel, data.stream);
|
2014-03-12 15:08:24 +00:00
|
|
|
|
|
|
|
if(isVideo) {
|
2014-03-26 18:06:34 +00:00
|
|
|
waitForRemoteVideo(sel, sid, thessrc);
|
2014-03-12 15:08:24 +00:00
|
|
|
}
|
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
data.stream.onended = function () {
|
|
|
|
console.log('stream ended', this.id);
|
2014-03-17 09:02:40 +00:00
|
|
|
|
2014-03-12 15:08:24 +00:00
|
|
|
// Mark video as removed to cancel waiting loop(if video is removed before has started)
|
|
|
|
sel.removed = true;
|
2014-03-17 09:02:40 +00:00
|
|
|
sel.remove();
|
2014-03-12 15:08:24 +00:00
|
|
|
|
2014-03-17 09:02:40 +00:00
|
|
|
var audioCount = $('#'+container.id+'>audio').length;
|
|
|
|
var videoCount = $('#'+container.id+'>video').length;
|
|
|
|
if(!audioCount && !videoCount) {
|
2014-03-12 15:08:24 +00:00
|
|
|
console.log("Remove whole user");
|
|
|
|
// Remove whole container
|
2014-03-17 09:02:40 +00:00
|
|
|
container.remove();
|
2014-03-12 15:08:24 +00:00
|
|
|
Util.playSoundNotification('userLeft');
|
|
|
|
resizeThumbnails();
|
|
|
|
}
|
2014-03-17 09:02:40 +00:00
|
|
|
|
|
|
|
checkChangeLargeVideo(vid.src);
|
2013-12-16 11:22:23 +00:00
|
|
|
};
|
2014-03-17 09:02:40 +00:00
|
|
|
|
|
|
|
// Add click handler
|
|
|
|
sel.click(function () { handleVideoThumbClicked(vid.src); });
|
|
|
|
|
2014-02-13 06:07:24 +00:00
|
|
|
// an attempt to work around https://github.com/jitsi/jitmeet/issues/32
|
2014-03-12 15:08:24 +00:00
|
|
|
if (isVideo
|
|
|
|
&& data.peerjid && sess.peerjid === data.peerjid &&
|
|
|
|
data.stream.getVideoTracks().length === 0 &&
|
|
|
|
connection.jingle.localVideo.getVideoTracks().length > 0) {
|
2014-02-13 06:07:24 +00:00
|
|
|
window.setTimeout(function() {
|
|
|
|
sendKeyframe(sess.peerconnection);
|
|
|
|
}, 3000);
|
|
|
|
}
|
2013-12-16 11:22:23 +00:00
|
|
|
});
|
|
|
|
|
2014-03-17 09:02:40 +00:00
|
|
|
function handleVideoThumbClicked(videoSrc) {
|
|
|
|
|
|
|
|
$(document).trigger("video.selected", [false]);
|
|
|
|
|
|
|
|
updateLargeVideo(videoSrc, 1);
|
|
|
|
|
|
|
|
$('audio').each(function (idx, el) {
|
2014-03-24 15:55:33 +00:00
|
|
|
if (el.id.indexOf('mixedmslabel') !== -1) {
|
2014-03-17 09:02:40 +00:00
|
|
|
el.volume = 0;
|
|
|
|
el.volume = 1;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if removed video is currently displayed and tries to display another one instead.
|
|
|
|
* @param removedVideoSrc src stream identifier of the video.
|
|
|
|
*/
|
|
|
|
function checkChangeLargeVideo(removedVideoSrc){
|
|
|
|
if (removedVideoSrc === $('#largeVideo').attr('src')) {
|
|
|
|
// this is currently displayed as large
|
|
|
|
// pick the last visible video in the row
|
|
|
|
// if nobody else is left, this picks the local video
|
|
|
|
var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last>video').get(0);
|
|
|
|
|
|
|
|
if(!pick) {
|
|
|
|
console.info("Last visible video no longer exists");
|
|
|
|
pick = $('#remoteVideos>span[id!="mixedstream"]>video').get(0);
|
2014-03-27 12:47:08 +00:00
|
|
|
if(!pick) {
|
|
|
|
// Try local video
|
|
|
|
console.info("Fallback to local video...");
|
|
|
|
pick = $('#remoteVideos>span>span>video').get(0);
|
|
|
|
}
|
2014-03-17 09:02:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// mute if localvideo
|
|
|
|
if (pick) {
|
|
|
|
updateLargeVideo(pick.src, pick.volume);
|
|
|
|
} else {
|
|
|
|
console.warn("Failed to elect large video");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-13 06:07:24 +00:00
|
|
|
// an attempt to work around https://github.com/jitsi/jitmeet/issues/32
|
|
|
|
function sendKeyframe(pc) {
|
|
|
|
console.log('sendkeyframe', pc.iceConnectionState);
|
2014-03-01 07:39:39 +00:00
|
|
|
if (pc.iceConnectionState !== 'connected') return; // safe...
|
2014-02-13 06:07:24 +00:00
|
|
|
pc.setRemoteDescription(
|
|
|
|
pc.remoteDescription,
|
|
|
|
function () {
|
|
|
|
pc.createAnswer(
|
|
|
|
function (modifiedAnswer) {
|
|
|
|
pc.setLocalDescription(modifiedAnswer,
|
|
|
|
function () {
|
|
|
|
},
|
|
|
|
function (error) {
|
|
|
|
console.log('triggerKeyframe setLocalDescription failed', error);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
|
|
|
function (error) {
|
|
|
|
console.log('triggerKeyframe createAnswer failed', error);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
|
|
|
function (error) {
|
|
|
|
console.log('triggerKeyframe setRemoteDescription failed', error);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-02-22 13:28:28 +00:00
|
|
|
// really mute video, i.e. dont even send black frames
|
|
|
|
function muteVideo(pc, unmute) {
|
|
|
|
// FIXME: this probably needs another of those lovely state safeguards...
|
|
|
|
// which checks for iceconn == connected and sigstate == stable
|
|
|
|
pc.setRemoteDescription(pc.remoteDescription,
|
|
|
|
function () {
|
|
|
|
pc.createAnswer(
|
|
|
|
function (answer) {
|
|
|
|
var sdp = new SDP(answer.sdp);
|
|
|
|
if (sdp.media.length > 1) {
|
|
|
|
if (unmute)
|
|
|
|
sdp.media[1] = sdp.media[1].replace('a=recvonly', 'a=sendrecv');
|
|
|
|
else
|
|
|
|
sdp.media[1] = sdp.media[1].replace('a=sendrecv', 'a=recvonly');
|
|
|
|
sdp.raw = sdp.session + sdp.media.join('');
|
|
|
|
answer.sdp = sdp.raw;
|
|
|
|
}
|
|
|
|
pc.setLocalDescription(answer,
|
|
|
|
function () {
|
|
|
|
console.log('mute SLD ok');
|
|
|
|
},
|
|
|
|
function(error) {
|
|
|
|
console.log('mute SLD error');
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
|
|
|
function (error) {
|
|
|
|
console.log(error);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
|
|
|
function (error) {
|
|
|
|
console.log('muteVideo SRD error');
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
$(document).bind('callincoming.jingle', function (event, sid) {
|
|
|
|
var sess = connection.jingle.sessions[sid];
|
2014-02-27 07:19:06 +00:00
|
|
|
|
|
|
|
// TODO: do we check activecall == null?
|
|
|
|
activecall = sess;
|
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
// TODO: check affiliation and/or role
|
|
|
|
console.log('emuc data for', sess.peerjid, connection.emuc.members[sess.peerjid]);
|
2014-01-26 12:04:53 +00:00
|
|
|
sess.usedrip = true; // not-so-naive trickle ice
|
2013-12-16 11:22:23 +00:00
|
|
|
sess.sendAnswer();
|
|
|
|
sess.accept();
|
2014-02-27 07:19:06 +00:00
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$(document).bind('callactive.jingle', function (event, videoelem, sid) {
|
2014-03-01 07:39:39 +00:00
|
|
|
if (videoelem.attr('id').indexOf('mixedmslabel') === -1) {
|
2013-12-16 11:22:23 +00:00
|
|
|
// ignore mixedmslabela0 and v0
|
|
|
|
videoelem.show();
|
|
|
|
resizeThumbnails();
|
|
|
|
|
2014-03-17 09:02:40 +00:00
|
|
|
updateLargeVideo(videoelem.attr('src'), 1);
|
2014-01-24 10:24:18 +00:00
|
|
|
|
2014-01-15 18:37:34 +00:00
|
|
|
showFocusIndicator();
|
2013-12-16 11:22:23 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).bind('callterminated.jingle', function (event, sid, reason) {
|
|
|
|
// FIXME
|
|
|
|
});
|
|
|
|
|
2014-01-09 20:44:37 +00:00
|
|
|
$(document).bind('setLocalDescription.jingle', function (event, sid) {
|
|
|
|
// put our ssrcs into presence so other clients can identify our stream
|
|
|
|
var sess = connection.jingle.sessions[sid];
|
|
|
|
var newssrcs = {};
|
2014-02-26 13:43:55 +00:00
|
|
|
var directions = {};
|
2014-01-09 20:44:37 +00:00
|
|
|
var localSDP = new SDP(sess.peerconnection.localDescription.sdp);
|
|
|
|
localSDP.media.forEach(function (media) {
|
|
|
|
var type = SDPUtil.parse_mline(media.split('\r\n')[0]).media;
|
2014-02-26 13:43:55 +00:00
|
|
|
|
2014-02-10 20:59:39 +00:00
|
|
|
if (SDPUtil.find_line(media, 'a=ssrc:')) {
|
|
|
|
// assumes a single local ssrc
|
2014-02-26 13:43:55 +00:00
|
|
|
var ssrc = SDPUtil.find_line(media, 'a=ssrc:').substring(7).split(' ')[0];
|
2014-02-10 20:59:39 +00:00
|
|
|
newssrcs[type] = ssrc;
|
2014-02-26 13:43:55 +00:00
|
|
|
|
2014-03-12 15:08:24 +00:00
|
|
|
directions[type] = (
|
|
|
|
SDPUtil.find_line(media, 'a=sendrecv')
|
|
|
|
|| SDPUtil.find_line(media, 'a=recvonly')
|
|
|
|
|| SDPUtil.find_line('a=sendonly')
|
|
|
|
|| SDPUtil.find_line('a=inactive')
|
|
|
|
|| 'a=sendrecv' ).substr(2);
|
2014-02-10 20:59:39 +00:00
|
|
|
}
|
2014-01-09 20:44:37 +00:00
|
|
|
});
|
|
|
|
console.log('new ssrcs', newssrcs);
|
|
|
|
|
2014-03-13 12:22:54 +00:00
|
|
|
// Have to clear presence map to get rid of removed streams
|
|
|
|
connection.emuc.clearPresenceMedia();
|
2014-01-24 10:24:18 +00:00
|
|
|
var i = 0;
|
2014-01-09 20:44:37 +00:00
|
|
|
Object.keys(newssrcs).forEach(function (mtype) {
|
2014-01-24 10:24:18 +00:00
|
|
|
i++;
|
2014-03-18 09:16:39 +00:00
|
|
|
var type = mtype;
|
|
|
|
// Change video type to screen
|
|
|
|
if(mtype === 'video' && isUsingScreenStream) {
|
|
|
|
type = 'screen';
|
|
|
|
}
|
|
|
|
connection.emuc.addMediaToPresence(i, type, newssrcs[mtype], directions[mtype]);
|
2014-01-09 20:44:37 +00:00
|
|
|
});
|
2014-02-10 20:59:39 +00:00
|
|
|
if (i > 0) {
|
|
|
|
connection.emuc.sendPresence();
|
|
|
|
}
|
2014-01-09 20:44:37 +00:00
|
|
|
});
|
2013-12-16 11:22:23 +00:00
|
|
|
|
|
|
|
$(document).bind('joined.muc', function (event, jid, info) {
|
|
|
|
updateRoomUrl(window.location.href);
|
2014-01-14 18:34:36 +00:00
|
|
|
document.getElementById('localNick').appendChild(
|
2014-02-11 14:05:17 +00:00
|
|
|
document.createTextNode(Strophe.getResourceFromJid(jid) + ' (me)')
|
2014-01-14 18:34:36 +00:00
|
|
|
);
|
2013-12-18 14:33:51 +00:00
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
if (Object.keys(connection.emuc.members).length < 1) {
|
|
|
|
focus = new ColibriFocus(connection, config.hosts.bridge);
|
|
|
|
}
|
2014-02-11 14:05:17 +00:00
|
|
|
|
2014-02-12 22:24:26 +00:00
|
|
|
if (focus && config.etherpad_base) {
|
|
|
|
Etherpad.init();
|
|
|
|
}
|
|
|
|
|
2014-02-11 14:05:17 +00:00
|
|
|
showFocusIndicator();
|
|
|
|
|
2014-01-24 10:24:18 +00:00
|
|
|
// Once we've joined the muc show the toolbar
|
|
|
|
showToolbar();
|
2014-02-11 14:05:17 +00:00
|
|
|
|
|
|
|
var displayName = '';
|
|
|
|
if (info.displayName)
|
|
|
|
displayName = info.displayName + ' (me)';
|
|
|
|
|
|
|
|
showDisplayName('localVideoContainer', displayName);
|
2013-12-16 11:22:23 +00:00
|
|
|
});
|
|
|
|
|
2014-01-09 20:44:37 +00:00
|
|
|
$(document).bind('entered.muc', function (event, jid, info, pres) {
|
2013-12-16 11:22:23 +00:00
|
|
|
console.log('entered', jid, info);
|
2014-03-12 15:08:24 +00:00
|
|
|
console.log('is focus?' + focus ? 'true' : 'false');
|
2014-02-11 14:05:17 +00:00
|
|
|
|
2014-03-27 09:30:53 +00:00
|
|
|
// Add Peer's container
|
|
|
|
ensurePeerContainerExists(jid);
|
2014-01-14 18:34:36 +00:00
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
if (focus !== null) {
|
|
|
|
// FIXME: this should prepare the video
|
|
|
|
if (focus.confid === null) {
|
|
|
|
console.log('make new conference with', jid);
|
|
|
|
focus.makeConference(Object.keys(connection.emuc.members));
|
|
|
|
} else {
|
|
|
|
console.log('invite', jid, 'into conference');
|
|
|
|
focus.addNewParticipant(jid);
|
|
|
|
}
|
|
|
|
}
|
2013-12-23 16:10:07 +00:00
|
|
|
else if (sharedKey) {
|
|
|
|
updateLockButton();
|
|
|
|
}
|
2013-12-16 11:22:23 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$(document).bind('left.muc', function (event, jid) {
|
|
|
|
console.log('left', jid);
|
|
|
|
connection.jingle.terminateByJid(jid);
|
2014-01-11 18:57:41 +00:00
|
|
|
var container = document.getElementById('participant_' + Strophe.getResourceFromJid(jid));
|
|
|
|
if (container) {
|
|
|
|
// hide here, wait for video to close before removing
|
2014-01-24 10:24:18 +00:00
|
|
|
$(container).hide();
|
2014-01-14 18:34:36 +00:00
|
|
|
resizeThumbnails();
|
2014-01-11 18:57:41 +00:00
|
|
|
}
|
2014-03-01 07:39:39 +00:00
|
|
|
if (focus === null && connection.emuc.myroomjid === connection.emuc.list_members[0]) {
|
2014-02-10 22:25:57 +00:00
|
|
|
console.log('welcome to our new focus... myself');
|
|
|
|
focus = new ColibriFocus(connection, config.hosts.bridge);
|
|
|
|
if (Object.keys(connection.emuc.members).length > 0) {
|
|
|
|
focus.makeConference(Object.keys(connection.emuc.members));
|
|
|
|
}
|
2014-02-12 22:24:26 +00:00
|
|
|
$(document).trigger('focusechanged.muc', [focus]);
|
2014-03-01 07:39:39 +00:00
|
|
|
}
|
2014-02-10 22:25:57 +00:00
|
|
|
else if (focus && Object.keys(connection.emuc.members).length === 0) {
|
2013-12-16 11:22:23 +00:00
|
|
|
console.log('everyone left');
|
2014-03-24 15:55:33 +00:00
|
|
|
// FIXME: closing the connection is a hack to avoid some
|
|
|
|
// problemswith reinit
|
|
|
|
disposeConference();
|
|
|
|
focus = new ColibriFocus(connection, config.hosts.bridge);
|
2013-12-16 11:22:23 +00:00
|
|
|
}
|
2014-01-24 10:24:18 +00:00
|
|
|
if (connection.emuc.getPrezi(jid)) {
|
|
|
|
$(document).trigger('presentationremoved.muc', [jid, connection.emuc.getPrezi(jid)]);
|
|
|
|
}
|
2013-12-16 11:22:23 +00:00
|
|
|
});
|
|
|
|
|
2014-01-09 20:44:37 +00:00
|
|
|
$(document).bind('presence.muc', function (event, jid, info, pres) {
|
2014-03-13 12:22:54 +00:00
|
|
|
|
|
|
|
// Remove old ssrcs coming from the jid
|
|
|
|
Object.keys(ssrc2jid).forEach(function(ssrc){
|
|
|
|
if(ssrc2jid[ssrc] == jid){
|
|
|
|
delete ssrc2jid[ssrc];
|
|
|
|
}
|
2014-03-26 18:06:34 +00:00
|
|
|
if(ssrc2videoType == jid){
|
|
|
|
delete ssrc2videoType[ssrc];
|
|
|
|
}
|
2014-03-13 12:22:54 +00:00
|
|
|
});
|
|
|
|
|
2014-01-09 20:44:37 +00:00
|
|
|
$(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
|
|
|
|
//console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
|
2014-03-26 18:06:34 +00:00
|
|
|
var ssrcV = ssrc.getAttribute('ssrc');
|
|
|
|
ssrc2jid[ssrcV] = jid;
|
2014-02-26 14:16:00 +00:00
|
|
|
|
2014-03-18 09:16:39 +00:00
|
|
|
var type = ssrc.getAttribute('type');
|
2014-03-26 18:06:34 +00:00
|
|
|
ssrc2videoType[ssrcV] = type;
|
|
|
|
|
2014-02-26 14:16:00 +00:00
|
|
|
// might need to update the direction if participant just went from sendrecv to recvonly
|
2014-03-18 09:16:39 +00:00
|
|
|
if (type === 'video' || type === 'screen') {
|
2014-02-26 17:18:08 +00:00
|
|
|
var el = $('#participant_' + Strophe.getResourceFromJid(jid) + '>video');
|
|
|
|
switch(ssrc.getAttribute('direction')) {
|
|
|
|
case 'sendrecv':
|
2014-03-01 07:39:39 +00:00
|
|
|
el.show();
|
2014-02-26 17:18:08 +00:00
|
|
|
break;
|
|
|
|
case 'recvonly':
|
|
|
|
el.hide();
|
2014-03-17 09:02:40 +00:00
|
|
|
// FIXME: Check if we have to change large video
|
|
|
|
//checkChangeLargeVideo(el);
|
2014-02-26 17:18:08 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-02-26 14:16:00 +00:00
|
|
|
}
|
2014-01-09 20:44:37 +00:00
|
|
|
});
|
2014-02-11 14:05:17 +00:00
|
|
|
|
|
|
|
if (info.displayName) {
|
2014-03-27 09:30:53 +00:00
|
|
|
if (jid === connection.emuc.myroomjid) {
|
2014-02-11 14:05:17 +00:00
|
|
|
showDisplayName('localVideoContainer', info.displayName + ' (me)');
|
2014-03-27 09:30:53 +00:00
|
|
|
} else {
|
|
|
|
ensurePeerContainerExists(jid);
|
2014-02-11 14:05:17 +00:00
|
|
|
showDisplayName('participant_' + Strophe.getResourceFromJid(jid), info.displayName);
|
2014-03-27 09:30:53 +00:00
|
|
|
}
|
2014-02-11 14:05:17 +00:00
|
|
|
}
|
2014-01-11 16:16:46 +00:00
|
|
|
});
|
|
|
|
|
2013-12-23 16:10:07 +00:00
|
|
|
$(document).bind('passwordrequired.muc', function (event, jid) {
|
|
|
|
console.log('on password required', jid);
|
|
|
|
|
|
|
|
$.prompt('<h2>Password required</h2>' +
|
|
|
|
'<input id="lockKey" type="text" placeholder="shared key" autofocus>',
|
|
|
|
{
|
|
|
|
persistent: true,
|
|
|
|
buttons: { "Ok": true , "Cancel": false},
|
|
|
|
defaultButton: 1,
|
|
|
|
loaded: function(event) {
|
|
|
|
document.getElementById('lockKey').focus();
|
|
|
|
},
|
|
|
|
submit: function(e,v,m,f){
|
|
|
|
if(v)
|
|
|
|
{
|
|
|
|
var lockKey = document.getElementById('lockKey');
|
|
|
|
|
2014-03-01 07:39:39 +00:00
|
|
|
if (lockKey.value !== null)
|
2013-12-23 16:10:07 +00:00
|
|
|
{
|
2014-02-11 14:05:17 +00:00
|
|
|
setSharedKey(lockKey.value);
|
2013-12-23 16:10:07 +00:00
|
|
|
connection.emuc.doJoin(jid, lockKey.value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2013-12-23 16:10:07 +00:00
|
|
|
});
|
|
|
|
|
2014-04-07 10:16:49 +00:00
|
|
|
$(document).bind('audiomuted.muc', function (event, jid, isMuted) {
|
|
|
|
var videoSpanId = null;
|
|
|
|
if (jid === connection.emuc.myroomjid) {
|
|
|
|
videoSpanId = 'localVideoContainer';
|
|
|
|
} else {
|
|
|
|
ensurePeerContainerExists(jid);
|
|
|
|
videoSpanId = 'participant_' + Strophe.getResourceFromJid(jid);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (videoSpanId)
|
|
|
|
showAudioIndicator(videoSpanId, isMuted);
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).bind('videomuted.muc', function (event, jid, isMuted) {
|
|
|
|
var videoSpanId = null;
|
|
|
|
if (jid === connection.emuc.myroomjid) {
|
|
|
|
videoSpanId = 'localVideoContainer';
|
|
|
|
} else {
|
|
|
|
ensurePeerContainerExists(jid);
|
|
|
|
videoSpanId = 'participant_' + Strophe.getResourceFromJid(jid);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (videoSpanId)
|
|
|
|
showAudioIndicator(videoSpanId, isMuted);
|
|
|
|
});
|
|
|
|
|
2014-01-11 16:16:46 +00:00
|
|
|
/**
|
|
|
|
* Updates the large video with the given new video source.
|
|
|
|
*/
|
2014-03-17 09:02:40 +00:00
|
|
|
function updateLargeVideo(newSrc, vol) {
|
2014-01-11 16:16:46 +00:00
|
|
|
console.log('hover in', newSrc);
|
2014-01-24 10:24:18 +00:00
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
if ($('#largeVideo').attr('src') != newSrc) {
|
2014-01-15 09:29:27 +00:00
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
var isVisible = $('#largeVideo').is(':visible');
|
2014-01-11 16:16:46 +00:00
|
|
|
|
|
|
|
$('#largeVideo').fadeOut(300, function () {
|
|
|
|
$(this).attr('src', newSrc);
|
|
|
|
|
2014-03-17 09:02:40 +00:00
|
|
|
// Screen stream is already rotated
|
|
|
|
var flipX = (newSrc === localVideoSrc) && flipXLocalVideo;
|
|
|
|
|
2014-01-11 16:16:46 +00:00
|
|
|
var videoTransform = document.getElementById('largeVideo').style.webkitTransform;
|
2014-03-17 09:02:40 +00:00
|
|
|
if (flipX && videoTransform !== 'scaleX(-1)') {
|
2014-01-11 16:16:46 +00:00
|
|
|
document.getElementById('largeVideo').style.webkitTransform = "scaleX(-1)";
|
|
|
|
}
|
2014-03-17 09:02:40 +00:00
|
|
|
else if (!flipX && videoTransform === 'scaleX(-1)') {
|
2014-01-11 16:16:46 +00:00
|
|
|
document.getElementById('largeVideo').style.webkitTransform = "none";
|
|
|
|
}
|
|
|
|
|
2014-03-28 09:37:14 +00:00
|
|
|
// Change the way we'll be measuring and positioning large video
|
|
|
|
var isDesktop = isVideoSrcDesktop(newSrc);
|
|
|
|
getVideoSize = isDesktop ? getDesktopVideoSize : getCameraVideoSize;
|
|
|
|
getVideoPosition = isDesktop ? getDesktopVideoPosition : getCameraVideoPosition;
|
2014-03-26 18:06:34 +00:00
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
if (isVisible)
|
|
|
|
$(this).fadeIn(300);
|
2014-01-11 16:16:46 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-26 18:06:34 +00:00
|
|
|
/**
|
|
|
|
* Checks if video identified by given src is desktop stream.
|
|
|
|
* @param videoSrc eg. blob:https%3A//pawel.jitsi.net/9a46e0bd-131e-4d18-9c14-a9264e8db395
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
function isVideoSrcDesktop(videoSrc){
|
|
|
|
// FIXME: fix this mapping mess...
|
|
|
|
// figure out if large video is desktop stream or just a camera
|
|
|
|
var isDesktop = false;
|
|
|
|
if(localVideoSrc === videoSrc) {
|
|
|
|
// local video
|
|
|
|
isDesktop = isUsingScreenStream;
|
|
|
|
} else {
|
|
|
|
// Do we have associations...
|
|
|
|
var videoSsrc = videoSrcToSsrc[videoSrc];
|
|
|
|
if(videoSsrc) {
|
|
|
|
var videoType = ssrc2videoType[videoSsrc];
|
|
|
|
if(videoType) {
|
|
|
|
// Finally there...
|
|
|
|
isDesktop = videoType === 'screen';
|
|
|
|
} else {
|
|
|
|
console.error("No video type for ssrc: " + videoSsrc);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
console.error("No ssrc for src: " + videoSrc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return isDesktop;
|
|
|
|
}
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
|
|
|
* Shows/hides the large video.
|
|
|
|
*/
|
|
|
|
function setLargeVideoVisible(isVisible) {
|
|
|
|
if (isVisible) {
|
|
|
|
$('#largeVideo').css({visibility:'visible'});
|
2014-04-07 10:16:49 +00:00
|
|
|
$('.watermark').css({visibility:'visible'});
|
2014-03-26 10:33:46 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#largeVideo').css({visibility:'hidden'});
|
2014-04-07 10:16:49 +00:00
|
|
|
$('.watermark').css({visibility:'hidden'});
|
2014-03-26 10:33:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-12 15:08:24 +00:00
|
|
|
function getConferenceHandler() {
|
|
|
|
return focus ? focus : activecall;
|
|
|
|
}
|
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
function toggleVideo() {
|
2014-04-07 10:16:49 +00:00
|
|
|
if (!(connection && connection.jingle.localVideo))
|
|
|
|
return;
|
2014-03-13 13:01:54 +00:00
|
|
|
|
2014-03-12 15:08:24 +00:00
|
|
|
var sess = getConferenceHandler();
|
|
|
|
if (sess) {
|
2014-03-13 13:01:54 +00:00
|
|
|
sess.toggleVideoMute(
|
|
|
|
function(isMuted){
|
|
|
|
if(isMuted) {
|
2014-04-07 10:16:49 +00:00
|
|
|
$('#video').removeClass("icon-camera");
|
|
|
|
$('#video').addClass("icon-camera icon-camera-disabled");
|
2014-03-13 13:01:54 +00:00
|
|
|
} else {
|
2014-04-07 10:16:49 +00:00
|
|
|
$('#video').removeClass("icon-camera icon-camera-disabled");
|
|
|
|
$('#video').addClass("icon-camera");
|
2014-03-13 13:01:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2014-02-27 07:19:06 +00:00
|
|
|
}
|
2014-04-07 10:16:49 +00:00
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
var sess = focus || activecall;
|
|
|
|
if (!sess) {
|
|
|
|
return;
|
|
|
|
}
|
2014-04-07 10:16:49 +00:00
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
sess.pendingop = ismuted ? 'unmute' : 'mute';
|
2014-04-07 10:16:49 +00:00
|
|
|
// connection.emuc.addVideoInfoToPresence(!ismuted);
|
|
|
|
// connection.emuc.sendPresence();
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
sess.modifySources();
|
2013-12-16 11:22:23 +00:00
|
|
|
}
|
|
|
|
|
2014-04-07 10:16:49 +00:00
|
|
|
/**
|
|
|
|
* Mutes / unmutes audio for the local participant.
|
|
|
|
*/
|
2013-12-16 11:22:23 +00:00
|
|
|
function toggleAudio() {
|
2014-04-07 10:16:49 +00:00
|
|
|
if (!(connection && connection.jingle.localAudio))
|
|
|
|
return;
|
2014-03-12 15:08:24 +00:00
|
|
|
var localAudio = connection.jingle.localAudio;
|
|
|
|
for (var idx = 0; idx < localAudio.getAudioTracks().length; idx++) {
|
2014-04-07 10:16:49 +00:00
|
|
|
var audioEnabled = localAudio.getAudioTracks()[idx].enabled;
|
|
|
|
|
|
|
|
localAudio.getAudioTracks()[idx].enabled = !audioEnabled;
|
|
|
|
connection.emuc.addAudioInfoToPresence(audioEnabled); //isMuted is the opposite of audioEnabled
|
|
|
|
connection.emuc.sendPresence();
|
2013-12-16 11:22:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
|
|
|
* Positions the large video.
|
|
|
|
*
|
|
|
|
* @param videoWidth the stream video width
|
|
|
|
* @param videoHeight the stream video height
|
|
|
|
*/
|
|
|
|
var positionLarge = function(videoWidth, videoHeight) {
|
|
|
|
var videoSpaceWidth = $('#videospace').width();
|
|
|
|
var videoSpaceHeight = window.innerHeight;
|
|
|
|
|
|
|
|
var videoSize = getVideoSize( videoWidth,
|
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight);
|
|
|
|
|
2014-03-26 18:06:34 +00:00
|
|
|
var largeVideoWidth = videoSize[0];
|
|
|
|
var largeVideoHeight = videoSize[1];
|
2014-03-26 10:33:46 +00:00
|
|
|
|
2014-03-26 18:06:34 +00:00
|
|
|
var videoPosition = getVideoPosition( largeVideoWidth,
|
|
|
|
largeVideoHeight,
|
2014-03-26 10:33:46 +00:00
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight);
|
|
|
|
|
|
|
|
var horizontalIndent = videoPosition[0];
|
|
|
|
var verticalIndent = videoPosition[1];
|
|
|
|
|
|
|
|
positionVideo( $('#largeVideo'),
|
2014-03-26 18:06:34 +00:00
|
|
|
largeVideoWidth,
|
|
|
|
largeVideoHeight,
|
2014-03-26 10:33:46 +00:00
|
|
|
horizontalIndent, verticalIndent);
|
|
|
|
};
|
2013-12-16 11:22:23 +00:00
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
|
|
|
* Returns an array of the video horizontal and vertical indents,
|
|
|
|
* so that if fits its parent.
|
|
|
|
*
|
|
|
|
* @return an array with 2 elements, the horizontal indent and the vertical
|
|
|
|
* indent
|
|
|
|
*/
|
2014-03-28 09:37:14 +00:00
|
|
|
function getCameraVideoPosition( videoWidth,
|
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight) {
|
2014-03-26 10:33:46 +00:00
|
|
|
// Parent height isn't completely calculated when we position the video in
|
|
|
|
// full screen mode and this is why we use the screen height in this case.
|
|
|
|
// Need to think it further at some point and implement it properly.
|
|
|
|
var isFullScreen = document.fullScreen
|
|
|
|
|| document.mozFullScreen
|
|
|
|
|| document.webkitIsFullScreen;
|
|
|
|
if (isFullScreen)
|
|
|
|
videoSpaceHeight = window.innerHeight;
|
|
|
|
|
|
|
|
var horizontalIndent = (videoSpaceWidth - videoWidth)/2;
|
|
|
|
var verticalIndent = (videoSpaceHeight - videoHeight)/2;
|
|
|
|
|
|
|
|
return [horizontalIndent, verticalIndent];
|
2014-03-28 09:37:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of the video horizontal and vertical indents.
|
|
|
|
* Centers horizontally and top aligns vertically.
|
|
|
|
*
|
|
|
|
* @return an array with 2 elements, the horizontal indent and the vertical
|
|
|
|
* indent
|
|
|
|
*/
|
|
|
|
function getDesktopVideoPosition( videoWidth,
|
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight) {
|
|
|
|
|
|
|
|
var horizontalIndent = (videoSpaceWidth - videoWidth)/2;
|
|
|
|
|
|
|
|
var verticalIndent = 0;// Top aligned
|
|
|
|
|
|
|
|
return [horizontalIndent, verticalIndent];
|
|
|
|
}
|
2013-12-16 11:22:23 +00:00
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
2014-03-26 18:06:34 +00:00
|
|
|
* Returns an array of the video dimensions, so that it covers the screen.
|
|
|
|
* It leaves no empty areas, but some parts of the video might not be visible.
|
2014-03-26 10:33:46 +00:00
|
|
|
*
|
|
|
|
* @return an array with 2 elements, the video width and the video height
|
|
|
|
*/
|
2014-03-28 09:37:14 +00:00
|
|
|
function getCameraVideoSize(videoWidth,
|
2014-03-26 18:06:34 +00:00
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight) {
|
2014-03-26 10:33:46 +00:00
|
|
|
if (!videoWidth)
|
|
|
|
videoWidth = currentVideoWidth;
|
|
|
|
if (!videoHeight)
|
|
|
|
videoHeight = currentVideoHeight;
|
|
|
|
|
|
|
|
var aspectRatio = videoWidth / videoHeight;
|
|
|
|
|
|
|
|
var availableWidth = Math.max(videoWidth, videoSpaceWidth);
|
|
|
|
var availableHeight = Math.max(videoHeight, videoSpaceHeight);
|
|
|
|
|
|
|
|
if (availableWidth / aspectRatio < videoSpaceHeight) {
|
|
|
|
availableHeight = videoSpaceHeight;
|
|
|
|
availableWidth = availableHeight*aspectRatio;
|
2013-12-16 11:22:23 +00:00
|
|
|
}
|
2014-01-28 14:11:05 +00:00
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
if (availableHeight*aspectRatio < videoSpaceWidth) {
|
|
|
|
availableWidth = videoSpaceWidth;
|
|
|
|
availableHeight = availableWidth / aspectRatio;
|
2014-01-28 14:11:05 +00:00
|
|
|
}
|
2014-02-12 22:24:26 +00:00
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
return [availableWidth, availableHeight];
|
2014-03-26 18:06:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of the video dimensions, so that it keeps it's aspect ratio and fits available area with it's
|
|
|
|
* larger dimension. This method ensures that whole video will be visible and can leave empty areas.
|
|
|
|
*
|
|
|
|
* @return an array with 2 elements, the video width and the video height
|
|
|
|
*/
|
2014-03-28 09:37:14 +00:00
|
|
|
function getDesktopVideoSize( videoWidth,
|
|
|
|
videoHeight,
|
|
|
|
videoSpaceWidth,
|
|
|
|
videoSpaceHeight )
|
|
|
|
{
|
2014-03-26 18:06:34 +00:00
|
|
|
if (!videoWidth)
|
|
|
|
videoWidth = currentVideoWidth;
|
|
|
|
if (!videoHeight)
|
|
|
|
videoHeight = currentVideoHeight;
|
|
|
|
|
|
|
|
var aspectRatio = videoWidth / videoHeight;
|
|
|
|
|
|
|
|
var availableWidth = Math.max(videoWidth, videoSpaceWidth);
|
|
|
|
var availableHeight = Math.max(videoHeight, videoSpaceHeight);
|
|
|
|
|
2014-03-28 09:37:14 +00:00
|
|
|
videoSpaceHeight -= $('#remoteVideos').outerHeight();
|
|
|
|
|
|
|
|
if (availableWidth / aspectRatio >= videoSpaceHeight)
|
|
|
|
{
|
2014-03-26 18:06:34 +00:00
|
|
|
availableHeight = videoSpaceHeight;
|
|
|
|
availableWidth = availableHeight*aspectRatio;
|
|
|
|
}
|
|
|
|
|
2014-03-28 09:37:14 +00:00
|
|
|
if (availableHeight*aspectRatio >= videoSpaceWidth)
|
|
|
|
{
|
2014-03-26 18:06:34 +00:00
|
|
|
availableWidth = videoSpaceWidth;
|
|
|
|
availableHeight = availableWidth / aspectRatio;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [availableWidth, availableHeight];
|
|
|
|
}
|
2014-03-26 10:33:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the size and position of the given video element.
|
|
|
|
*
|
|
|
|
* @param video the video element to position
|
|
|
|
* @param width the desired video width
|
|
|
|
* @param height the desired video height
|
|
|
|
* @param horizontalIndent the left and right indent
|
|
|
|
* @param verticalIndent the top and bottom indent
|
|
|
|
*/
|
|
|
|
function positionVideo( video,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
horizontalIndent,
|
|
|
|
verticalIndent) {
|
|
|
|
video.width(width);
|
|
|
|
video.height(height);
|
|
|
|
video.css({ top: verticalIndent + 'px',
|
|
|
|
bottom: verticalIndent + 'px',
|
|
|
|
left: horizontalIndent + 'px',
|
|
|
|
right: horizontalIndent + 'px'});
|
|
|
|
}
|
|
|
|
|
|
|
|
var resizeLargeVideoContainer = function () {
|
|
|
|
Chat.resizeChat();
|
|
|
|
var availableHeight = window.innerHeight;
|
|
|
|
var availableWidth = Util.getAvailableVideoWidth();
|
|
|
|
|
|
|
|
if (availableWidth < 0 || availableHeight < 0) return;
|
|
|
|
|
|
|
|
$('#videospace').width(availableWidth);
|
|
|
|
$('#videospace').height(availableHeight);
|
|
|
|
$('#largeVideoContainer').width(availableWidth);
|
|
|
|
$('#largeVideoContainer').height(availableHeight);
|
2014-02-12 22:24:26 +00:00
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
resizeThumbnails();
|
2014-02-18 19:11:27 +00:00
|
|
|
};
|
2013-12-16 11:22:23 +00:00
|
|
|
|
2014-03-31 12:49:33 +00:00
|
|
|
var calculateThumbnailSize = function() {
|
|
|
|
// Calculate the available height, which is the inner window height minus
|
2014-03-26 10:33:46 +00:00
|
|
|
// 39px for the header minus 2px for the delimiter lines on the top and
|
|
|
|
// bottom of the large video, minus the 36px space inside the remoteVideos
|
|
|
|
// container used for highlighting shadow.
|
|
|
|
var availableHeight = 100;
|
|
|
|
|
2013-12-23 16:49:29 +00:00
|
|
|
var numvids = $('#remoteVideos>span:visible').length;
|
2014-01-28 14:11:05 +00:00
|
|
|
|
|
|
|
// Remove the 1px borders arround videos and the chat width.
|
2014-02-05 13:01:22 +00:00
|
|
|
var availableWinWidth = $('#remoteVideos').width() - 2 * numvids - 50;
|
2013-12-16 11:22:23 +00:00
|
|
|
var availableWidth = availableWinWidth / numvids;
|
|
|
|
var aspectRatio = 16.0 / 9.0;
|
|
|
|
var maxHeight = Math.min(160, availableHeight);
|
|
|
|
availableHeight = Math.min(maxHeight, availableWidth / aspectRatio);
|
|
|
|
if (availableHeight < availableWidth / aspectRatio) {
|
|
|
|
availableWidth = Math.floor(availableHeight * aspectRatio);
|
|
|
|
}
|
2014-02-05 13:01:22 +00:00
|
|
|
|
2014-03-31 12:49:33 +00:00
|
|
|
return [availableWidth, availableHeight];
|
|
|
|
};
|
|
|
|
|
|
|
|
function resizeThumbnails() {
|
|
|
|
var thumbnailSize = calculateThumbnailSize();
|
|
|
|
var width = thumbnailSize[0];
|
|
|
|
var height = thumbnailSize[1];
|
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
// size videos so that while keeping AR and max height, we have a nice fit
|
2014-03-31 12:49:33 +00:00
|
|
|
$('#remoteVideos').height(height);
|
|
|
|
$('#remoteVideos>span').width(width);
|
|
|
|
$('#remoteVideos>span').height(height);
|
2013-12-16 11:22:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
2014-02-18 19:11:27 +00:00
|
|
|
Chat.init();
|
2013-12-16 11:22:23 +00:00
|
|
|
|
2014-01-24 10:24:18 +00:00
|
|
|
// Set the defaults for prompt dialogs.
|
|
|
|
jQuery.prompt.setDefaults({persistent: false});
|
|
|
|
|
2014-03-26 11:32:42 +00:00
|
|
|
// Set default desktop sharing method
|
|
|
|
setDesktopSharing(config.desktopSharing);
|
2014-04-01 11:19:11 +00:00
|
|
|
// Initialize Chrome extension inline installs
|
|
|
|
if(config.chromeExtensionId)
|
|
|
|
{
|
|
|
|
initInlineInstalls();
|
|
|
|
}
|
2014-03-26 11:32:42 +00:00
|
|
|
|
2014-03-28 09:37:14 +00:00
|
|
|
// By default we use camera
|
|
|
|
getVideoSize = getCameraVideoSize;
|
|
|
|
getVideoPosition = getCameraVideoPosition;
|
2014-03-26 18:06:34 +00:00
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
resizeLargeVideoContainer();
|
2013-12-16 11:22:23 +00:00
|
|
|
$(window).resize(function () {
|
2014-03-26 10:33:46 +00:00
|
|
|
resizeLargeVideoContainer();
|
|
|
|
positionLarge();
|
2013-12-16 11:22:23 +00:00
|
|
|
});
|
2014-03-26 18:06:34 +00:00
|
|
|
// Listen for large video size updates
|
|
|
|
document.getElementById('largeVideo')
|
|
|
|
.addEventListener('loadedmetadata', function(e){
|
|
|
|
currentVideoWidth = this.videoWidth;
|
|
|
|
currentVideoHeight = this.videoHeight;
|
|
|
|
positionLarge(currentVideoWidth, currentVideoHeight);
|
|
|
|
});
|
|
|
|
|
2013-12-16 11:22:23 +00:00
|
|
|
if (!$('#settings').is(':visible')) {
|
|
|
|
console.log('init');
|
|
|
|
init();
|
|
|
|
} else {
|
|
|
|
loginInfo.onsubmit = function (e) {
|
|
|
|
if (e.preventDefault) e.preventDefault();
|
|
|
|
$('#settings').hide();
|
|
|
|
init();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-12-30 08:31:08 +00:00
|
|
|
$(window).bind('beforeunload', function () {
|
2013-12-16 11:22:23 +00:00
|
|
|
if (connection && connection.connected) {
|
|
|
|
// ensure signout
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: config.bosh,
|
|
|
|
async: false,
|
|
|
|
cache: false,
|
|
|
|
contentType: 'application/xml',
|
|
|
|
data: "<body rid='" + (connection.rid || connection._proto.rid) + "' xmlns='http://jabber.org/protocol/httpbind' sid='" + (connection.sid || connection._proto.sid) + "' type='terminate'><presence xmlns='jabber:client' type='unavailable'/></body>",
|
|
|
|
success: function (data) {
|
|
|
|
console.log('signed out');
|
|
|
|
console.log(data);
|
|
|
|
},
|
|
|
|
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
|
|
console.log('signout error', textStatus + ' (' + errorThrown + ')');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-03-24 15:55:33 +00:00
|
|
|
disposeConference();
|
2013-12-16 11:22:23 +00:00
|
|
|
});
|
|
|
|
|
2014-03-24 15:55:33 +00:00
|
|
|
function disposeConference() {
|
|
|
|
var handler = getConferenceHandler();
|
2014-03-24 17:31:59 +00:00
|
|
|
if(handler && handler.peerconnection) {
|
|
|
|
// FIXME: probably removing streams is not required and close() should be enough
|
2014-03-24 15:55:33 +00:00
|
|
|
if(connection.jingle.localAudio) {
|
|
|
|
handler.peerconnection.removeStream(connection.jingle.localAudio);
|
|
|
|
}
|
|
|
|
if(connection.jingle.localVideo) {
|
|
|
|
handler.peerconnection.removeStream(connection.jingle.localVideo);
|
|
|
|
}
|
|
|
|
handler.peerconnection.close();
|
|
|
|
}
|
|
|
|
focus = null;
|
|
|
|
activecall = null;
|
|
|
|
}
|
|
|
|
|
2014-01-15 09:18:23 +00:00
|
|
|
function dump(elem, filename){
|
2013-12-22 18:46:01 +00:00
|
|
|
elem = elem.parentNode;
|
2014-01-15 09:18:23 +00:00
|
|
|
elem.download = filename || 'meetlog.json';
|
2013-12-22 18:39:41 +00:00
|
|
|
elem.href = 'data:application/json;charset=utf-8,\n';
|
|
|
|
var data = {};
|
|
|
|
if (connection.jingle) {
|
|
|
|
Object.keys(connection.jingle.sessions).forEach(function (sid) {
|
|
|
|
var session = connection.jingle.sessions[sid];
|
|
|
|
if (session.peerconnection && session.peerconnection.updateLog) {
|
|
|
|
// FIXME: should probably be a .dump call
|
2014-01-15 09:18:23 +00:00
|
|
|
data["jingle_" + session.sid] = {
|
|
|
|
updateLog: session.peerconnection.updateLog,
|
2014-02-05 20:34:59 +00:00
|
|
|
stats: session.peerconnection.stats,
|
2014-01-15 09:18:23 +00:00
|
|
|
url: window.location.href}
|
|
|
|
;
|
2013-12-22 18:39:41 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-01-15 09:18:23 +00:00
|
|
|
metadata = {};
|
|
|
|
metadata.time = new Date();
|
|
|
|
metadata.url = window.location.href;
|
|
|
|
metadata.ua = navigator.userAgent;
|
|
|
|
if (connection.logger) {
|
|
|
|
metadata.xmpp = connection.logger.log;
|
|
|
|
}
|
|
|
|
data.metadata = metadata;
|
2013-12-22 18:39:41 +00:00
|
|
|
elem.href += encodeURIComponent(JSON.stringify(data, null, ' '));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
2013-12-20 14:19:17 +00:00
|
|
|
* Changes the style class of the element given by id.
|
|
|
|
*/
|
2013-12-16 11:22:23 +00:00
|
|
|
function buttonClick(id, classname) {
|
|
|
|
$(id).toggleClass(classname); // add the class to the clicked element
|
|
|
|
}
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
2013-12-20 14:19:17 +00:00
|
|
|
* Opens the lock room dialog.
|
|
|
|
*/
|
2013-12-16 11:22:23 +00:00
|
|
|
function openLockDialog() {
|
2013-12-23 16:10:07 +00:00
|
|
|
// Only the focus is able to set a shared key.
|
2014-03-01 07:39:39 +00:00
|
|
|
if (focus === null) {
|
2013-12-23 16:10:07 +00:00
|
|
|
if (sharedKey)
|
|
|
|
$.prompt("This conversation is currently protected by a shared secret key.",
|
|
|
|
{
|
|
|
|
title: "Secrect key",
|
|
|
|
persistent: false
|
|
|
|
});
|
|
|
|
else
|
|
|
|
$.prompt("This conversation isn't currently protected by a secret key. Only the owner of the conference could set a shared key.",
|
|
|
|
{
|
|
|
|
title: "Secrect key",
|
|
|
|
persistent: false
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (sharedKey)
|
|
|
|
$.prompt("Are you sure you would like to remove your secret key?",
|
|
|
|
{
|
|
|
|
title: "Remove secrect key",
|
|
|
|
persistent: false,
|
|
|
|
buttons: { "Remove": true, "Cancel": false},
|
|
|
|
defaultButton: 1,
|
|
|
|
submit: function(e,v,m,f){
|
|
|
|
if(v)
|
|
|
|
{
|
|
|
|
setSharedKey('');
|
2014-01-03 16:41:50 +00:00
|
|
|
lockRoom(false);
|
2013-12-23 16:10:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
else
|
|
|
|
$.prompt('<h2>Set a secrect key to lock your room</h2>' +
|
|
|
|
'<input id="lockKey" type="text" placeholder="your shared key" autofocus>',
|
|
|
|
{
|
|
|
|
persistent: false,
|
|
|
|
buttons: { "Save": true , "Cancel": false},
|
|
|
|
defaultButton: 1,
|
|
|
|
loaded: function(event) {
|
|
|
|
document.getElementById('lockKey').focus();
|
|
|
|
},
|
|
|
|
submit: function(e,v,m,f){
|
|
|
|
if(v)
|
|
|
|
{
|
2014-01-24 10:24:18 +00:00
|
|
|
var lockKey = document.getElementById('lockKey');
|
2014-02-26 15:19:39 +00:00
|
|
|
|
2014-01-24 10:24:18 +00:00
|
|
|
if (lockKey.value)
|
|
|
|
{
|
2014-02-26 15:19:39 +00:00
|
|
|
setSharedKey(Util.escapeHtml(lockKey.value));
|
2014-01-24 10:24:18 +00:00
|
|
|
lockRoom(true);
|
|
|
|
}
|
2013-12-23 16:10:07 +00:00
|
|
|
}
|
2013-12-16 11:22:23 +00:00
|
|
|
}
|
2014-01-24 10:24:18 +00:00
|
|
|
});
|
2013-12-23 16:10:07 +00:00
|
|
|
}
|
2013-12-16 11:22:23 +00:00
|
|
|
}
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
2013-12-20 14:19:17 +00:00
|
|
|
* Opens the invite link dialog.
|
|
|
|
*/
|
2013-12-16 11:22:23 +00:00
|
|
|
function openLinkDialog() {
|
2014-02-26 15:19:39 +00:00
|
|
|
$.prompt('<input id="inviteLinkRef" type="text" value="'
|
|
|
|
+ encodeURI(roomUrl) + '" onclick="this.select();" readonly>',
|
2013-12-16 11:22:23 +00:00
|
|
|
{
|
|
|
|
title: "Share this link with everyone you want to invite",
|
|
|
|
persistent: false,
|
|
|
|
buttons: { "Cancel": false},
|
|
|
|
loaded: function(event) {
|
|
|
|
document.getElementById('inviteLinkRef').select();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
2014-01-24 10:24:18 +00:00
|
|
|
* Opens the settings dialog.
|
|
|
|
*/
|
|
|
|
function openSettingsDialog() {
|
|
|
|
$.prompt('<h2>Configure your conference</h2>' +
|
|
|
|
'<input type="checkbox" id="initMuted"> Participants join muted<br/>' +
|
|
|
|
'<input type="checkbox" id="requireNicknames"> Require nicknames<br/><br/>' +
|
|
|
|
'Set a secrect key to lock your room: <input id="lockKey" type="text" placeholder="your shared key" autofocus>',
|
|
|
|
{
|
|
|
|
persistent: false,
|
|
|
|
buttons: { "Save": true , "Cancel": false},
|
|
|
|
defaultButton: 1,
|
|
|
|
loaded: function(event) {
|
|
|
|
document.getElementById('lockKey').focus();
|
|
|
|
},
|
|
|
|
submit: function(e,v,m,f){
|
|
|
|
if(v)
|
|
|
|
{
|
|
|
|
if ($('#initMuted').is(":checked"))
|
|
|
|
{
|
|
|
|
// it is checked
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($('#requireNicknames').is(":checked"))
|
|
|
|
{
|
2014-02-26 15:19:39 +00:00
|
|
|
// it is checked
|
2014-01-24 10:24:18 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
var lockKey = document.getElementById('lockKey');
|
2014-03-01 07:39:39 +00:00
|
|
|
|
2014-01-24 10:24:18 +00:00
|
|
|
if (lockKey.value)
|
|
|
|
{
|
|
|
|
setSharedKey(lockKey.value);
|
|
|
|
lockRoom(true);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
2013-12-20 14:19:17 +00:00
|
|
|
* Locks / unlocks the room.
|
|
|
|
*/
|
2013-12-16 11:22:23 +00:00
|
|
|
function lockRoom(lock) {
|
2014-01-03 16:41:50 +00:00
|
|
|
if (lock)
|
|
|
|
connection.emuc.lockRoom(sharedKey);
|
|
|
|
else
|
|
|
|
connection.emuc.lockRoom('');
|
2014-02-26 15:19:39 +00:00
|
|
|
|
2013-12-23 16:10:07 +00:00
|
|
|
updateLockButton();
|
|
|
|
}
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
2013-12-23 16:10:07 +00:00
|
|
|
* Sets the shared key.
|
|
|
|
*/
|
|
|
|
function setSharedKey(sKey) {
|
|
|
|
sharedKey = sKey;
|
|
|
|
}
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
2013-12-23 16:10:07 +00:00
|
|
|
* Updates the lock button state.
|
|
|
|
*/
|
|
|
|
function updateLockButton() {
|
2014-03-26 10:33:46 +00:00
|
|
|
buttonClick("#lockIcon", "icon-security icon-security-locked");
|
2013-12-16 11:22:23 +00:00
|
|
|
}
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
|
|
|
* Hides the toolbar.
|
|
|
|
*/
|
|
|
|
var hideToolbar = function() {
|
|
|
|
|
|
|
|
var isToolbarHover = false;
|
|
|
|
$('#header').find('*').each(function(){
|
|
|
|
var id = $(this).attr('id');
|
|
|
|
if ($("#" + id + ":hover").length > 0) {
|
|
|
|
isToolbarHover = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
clearTimeout(toolbarTimeout);
|
|
|
|
toolbarTimeout = null;
|
|
|
|
|
|
|
|
if (!isToolbarHover) {
|
|
|
|
$('#header').hide("slide", { direction: "up", duration: 300});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
toolbarTimeout = setTimeout(hideToolbar, 2000);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-12-20 14:19:17 +00:00
|
|
|
* Shows the call main toolbar.
|
|
|
|
*/
|
2013-12-18 14:33:51 +00:00
|
|
|
function showToolbar() {
|
2014-03-26 10:33:46 +00:00
|
|
|
if (!$('#header').is(':visible')) {
|
|
|
|
$('#header').show("slide", { direction: "up", duration: 300});
|
|
|
|
|
|
|
|
if (toolbarTimeout) {
|
|
|
|
clearTimeout(toolbarTimeout);
|
|
|
|
toolbarTimeout = null;
|
|
|
|
}
|
|
|
|
toolbarTimeout = setTimeout(hideToolbar, 2000);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (focus != null)
|
2014-01-24 10:24:18 +00:00
|
|
|
{
|
|
|
|
// TODO: Enable settings functionality. Need to uncomment the settings button in index.html.
|
|
|
|
// $('#settingsButton').css({visibility:"visible"});
|
|
|
|
}
|
2014-03-26 11:32:42 +00:00
|
|
|
|
|
|
|
// Show/hide desktop sharing button
|
|
|
|
showDesktopSharingButton();
|
2013-12-18 14:33:51 +00:00
|
|
|
}
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
|
|
|
* Docks/undocks the toolbar.
|
|
|
|
*
|
|
|
|
* @param isDock indicates what operation to perform
|
|
|
|
*/
|
|
|
|
function dockToolbar(isDock) {
|
|
|
|
if (isDock) {
|
|
|
|
// First make sure the toolbar is shown.
|
|
|
|
if (!$('#header').is(':visible')) {
|
|
|
|
showToolbar();
|
|
|
|
}
|
|
|
|
// Then clear the time out, to dock the toolbar.
|
|
|
|
clearTimeout(toolbarTimeout);
|
|
|
|
toolbarTimeout = null;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!$('#header').is(':visible')) {
|
|
|
|
showToolbar();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
toolbarTimeout = setTimeout(hideToolbar, 2000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-20 14:19:17 +00:00
|
|
|
* Updates the room invite url.
|
|
|
|
*/
|
2013-12-16 11:22:23 +00:00
|
|
|
function updateRoomUrl(newRoomUrl) {
|
|
|
|
roomUrl = newRoomUrl;
|
|
|
|
}
|
2013-12-20 14:19:17 +00:00
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
2013-12-20 14:19:17 +00:00
|
|
|
* Warning to the user that the conference window is about to be closed.
|
|
|
|
*/
|
|
|
|
function closePageWarning() {
|
2014-03-01 07:39:39 +00:00
|
|
|
if (focus !== null)
|
2013-12-20 14:19:17 +00:00
|
|
|
return "You are the owner of this conference call and you are about to end it.";
|
|
|
|
else
|
|
|
|
return "You are about to leave this conversation.";
|
|
|
|
}
|
2014-01-15 09:29:27 +00:00
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
2014-01-15 09:29:27 +00:00
|
|
|
* Shows a visual indicator for the focus of the conference.
|
2014-01-15 18:37:34 +00:00
|
|
|
* Currently if we're not the owner of the conference we obtain the focus
|
|
|
|
* from the connection.jingle.sessions.
|
2014-01-15 09:29:27 +00:00
|
|
|
*/
|
|
|
|
function showFocusIndicator() {
|
2014-03-01 07:39:39 +00:00
|
|
|
if (focus !== null) {
|
2014-02-11 14:05:17 +00:00
|
|
|
var indicatorSpan = $('#localVideoContainer .focusindicator');
|
2014-01-15 09:29:27 +00:00
|
|
|
|
2014-03-01 07:39:39 +00:00
|
|
|
if (indicatorSpan.children().length === 0)
|
2014-01-15 18:37:34 +00:00
|
|
|
{
|
2014-02-11 14:05:17 +00:00
|
|
|
createFocusIndicatorElement(indicatorSpan[0]);
|
2014-01-15 18:37:34 +00:00
|
|
|
}
|
2014-01-15 09:29:27 +00:00
|
|
|
}
|
2014-01-15 18:37:34 +00:00
|
|
|
else if (Object.keys(connection.jingle.sessions).length > 0) {
|
|
|
|
// If we're only a participant the focus will be the only session we have.
|
|
|
|
var session = connection.jingle.sessions[Object.keys(connection.jingle.sessions)[0]];
|
|
|
|
var focusId = 'participant_' + Strophe.getResourceFromJid(session.peerjid);
|
|
|
|
var focusContainer = document.getElementById(focusId);
|
2014-03-12 15:08:24 +00:00
|
|
|
if(!focusContainer) {
|
|
|
|
console.error("No focus container!");
|
|
|
|
return;
|
|
|
|
}
|
2014-01-15 18:37:34 +00:00
|
|
|
var indicatorSpan = $('#' + focusId + ' .focusindicator');
|
|
|
|
|
2014-03-01 07:39:39 +00:00
|
|
|
if (!indicatorSpan || indicatorSpan.length === 0) {
|
2014-01-15 18:37:34 +00:00
|
|
|
indicatorSpan = document.createElement('span');
|
|
|
|
indicatorSpan.className = 'focusindicator';
|
|
|
|
focusContainer.appendChild(indicatorSpan);
|
2014-03-01 07:39:39 +00:00
|
|
|
|
2014-01-15 18:37:34 +00:00
|
|
|
createFocusIndicatorElement(indicatorSpan);
|
|
|
|
}
|
2014-01-15 09:29:27 +00:00
|
|
|
}
|
|
|
|
}
|
2014-01-15 18:37:34 +00:00
|
|
|
|
2014-03-27 09:30:53 +00:00
|
|
|
/**
|
|
|
|
* Checks if container for participant identified by given peerJid exists in the document and creates it eventually.
|
|
|
|
* @param peerJid peer Jid to check.
|
|
|
|
*/
|
|
|
|
function ensurePeerContainerExists(peerJid){
|
|
|
|
|
|
|
|
var peerResource = Strophe.getResourceFromJid(peerJid);
|
|
|
|
var videoSpanId = 'participant_' + peerResource;
|
|
|
|
|
|
|
|
if($('#'+videoSpanId).length > 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var container = addRemoteVideoContainer(videoSpanId);
|
|
|
|
|
|
|
|
var nickfield = document.createElement('span');
|
|
|
|
nickfield.className = "nick";
|
|
|
|
nickfield.appendChild(document.createTextNode(peerResource));
|
|
|
|
container.appendChild(nickfield);
|
|
|
|
resizeThumbnails();
|
|
|
|
}
|
|
|
|
|
2014-01-24 10:24:18 +00:00
|
|
|
function addRemoteVideoContainer(id) {
|
|
|
|
var container = document.createElement('span');
|
|
|
|
container.id = id;
|
|
|
|
container.className = 'videocontainer';
|
|
|
|
var remotes = document.getElementById('remoteVideos');
|
|
|
|
remotes.appendChild(container);
|
|
|
|
return container;
|
|
|
|
}
|
|
|
|
|
2014-02-18 19:11:27 +00:00
|
|
|
/**
|
2014-01-15 18:37:34 +00:00
|
|
|
* Creates the element indicating the focus of the conference.
|
|
|
|
*/
|
|
|
|
function createFocusIndicatorElement(parentElement) {
|
|
|
|
var focusIndicator = document.createElement('i');
|
|
|
|
focusIndicator.className = 'fa fa-star';
|
2014-03-01 07:39:39 +00:00
|
|
|
focusIndicator.title = "The owner of this conference";
|
2014-01-15 18:37:34 +00:00
|
|
|
parentElement.appendChild(focusIndicator);
|
|
|
|
}
|
2014-02-05 13:01:22 +00:00
|
|
|
|
2014-02-18 19:11:27 +00:00
|
|
|
/**
|
2014-03-01 07:39:39 +00:00
|
|
|
* Toggles the application in and out of full screen mode
|
2014-02-09 11:21:18 +00:00
|
|
|
* (a.k.a. presentation mode in Chrome).
|
|
|
|
*/
|
2014-02-11 14:05:17 +00:00
|
|
|
function toggleFullScreen() {
|
2014-02-09 11:21:18 +00:00
|
|
|
var fsElement = document.documentElement;
|
|
|
|
|
2014-02-09 12:03:24 +00:00
|
|
|
if (!document.mozFullScreen && !document.webkitIsFullScreen){
|
2014-02-09 11:21:18 +00:00
|
|
|
|
|
|
|
//Enter Full Screen
|
|
|
|
if (fsElement.mozRequestFullScreen) {
|
|
|
|
fsElement.mozRequestFullScreen();
|
2014-03-01 07:39:39 +00:00
|
|
|
}
|
2014-02-09 11:21:18 +00:00
|
|
|
else {
|
|
|
|
fsElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//Exit Full Screen
|
|
|
|
if (document.mozCancelFullScreen) {
|
|
|
|
document.mozCancelFullScreen();
|
|
|
|
} else {
|
|
|
|
document.webkitCancelFullScreen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-02-11 14:05:17 +00:00
|
|
|
|
|
|
|
/**
|
2014-02-18 19:11:27 +00:00
|
|
|
* Shows the display name for the given video.
|
2014-02-11 14:05:17 +00:00
|
|
|
*/
|
|
|
|
function showDisplayName(videoSpanId, displayName) {
|
|
|
|
var nameSpan = $('#' + videoSpanId + '>span.displayname');
|
|
|
|
|
|
|
|
// If we already have a display name for this video.
|
|
|
|
if (nameSpan.length > 0) {
|
|
|
|
var nameSpanElement = nameSpan.get(0);
|
|
|
|
|
2014-03-01 07:39:39 +00:00
|
|
|
if (nameSpanElement.id === 'localDisplayName'
|
2014-03-31 12:49:33 +00:00
|
|
|
&& $('#localDisplayName').text() !== displayName)
|
|
|
|
$('#localDisplayName').text(displayName);
|
2014-02-11 14:05:17 +00:00
|
|
|
else
|
2014-03-31 12:49:33 +00:00
|
|
|
$('#' + videoSpanId + '_name').text(displayName);
|
2014-02-11 14:05:17 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
var editButton = null;
|
2014-02-26 15:19:39 +00:00
|
|
|
|
2014-03-01 07:39:39 +00:00
|
|
|
if (videoSpanId === 'localVideoContainer') {
|
2014-02-11 14:05:17 +00:00
|
|
|
editButton = createEditDisplayNameButton();
|
|
|
|
}
|
2014-03-31 12:49:33 +00:00
|
|
|
if (displayName.length) {
|
2014-02-11 14:05:17 +00:00
|
|
|
nameSpan = document.createElement('span');
|
|
|
|
nameSpan.className = 'displayname';
|
2014-03-31 12:49:33 +00:00
|
|
|
nameSpan.innerText = displayName;
|
2014-02-11 14:05:17 +00:00
|
|
|
$('#' + videoSpanId)[0].appendChild(nameSpan);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!editButton) {
|
|
|
|
nameSpan.id = videoSpanId + '_name';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nameSpan.id = 'localDisplayName';
|
|
|
|
$('#' + videoSpanId)[0].appendChild(editButton);
|
2014-02-26 15:19:39 +00:00
|
|
|
|
2014-02-11 14:05:17 +00:00
|
|
|
var editableText = document.createElement('input');
|
|
|
|
editableText.className = 'displayname';
|
|
|
|
editableText.id = 'editDisplayName';
|
|
|
|
|
2014-03-31 12:49:33 +00:00
|
|
|
if (displayName.length)
|
2014-02-26 15:19:39 +00:00
|
|
|
editableText.value
|
2014-03-31 12:49:33 +00:00
|
|
|
= displayName.substring(0, displayName.indexOf(' (me)'));
|
2014-02-11 14:05:17 +00:00
|
|
|
|
|
|
|
editableText.setAttribute('style', 'display:none;');
|
|
|
|
editableText.setAttribute('placeholder', 'ex. Jane Pink');
|
|
|
|
$('#' + videoSpanId)[0].appendChild(editableText);
|
|
|
|
|
|
|
|
$('#localVideoContainer .displayname').bind("click", function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
$('#localDisplayName').hide();
|
|
|
|
$('#editDisplayName').show();
|
|
|
|
$('#editDisplayName').focus();
|
|
|
|
$('#editDisplayName').select();
|
|
|
|
|
|
|
|
var inputDisplayNameHandler = function(name) {
|
2014-03-01 07:39:39 +00:00
|
|
|
if (nickname !== name) {
|
2014-03-31 12:49:33 +00:00
|
|
|
nickname = name;
|
2014-02-11 14:05:17 +00:00
|
|
|
window.localStorage.displayname = nickname;
|
|
|
|
connection.emuc.addDisplayNameToPresence(nickname);
|
|
|
|
connection.emuc.sendPresence();
|
2014-02-11 15:27:49 +00:00
|
|
|
|
2014-02-18 19:11:27 +00:00
|
|
|
Chat.setChatConversationMode(true);
|
2014-02-11 14:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!$('#localDisplayName').is(":visible")) {
|
2014-03-31 12:49:33 +00:00
|
|
|
$('#localDisplayName').text(nickname + " (me)");
|
2014-02-11 14:05:17 +00:00
|
|
|
$('#localDisplayName').show();
|
|
|
|
$('#editDisplayName').hide();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$('#editDisplayName').one("focusout", function (e) {
|
|
|
|
inputDisplayNameHandler(this.value);
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#editDisplayName').on('keydown', function (e) {
|
2014-03-01 07:39:39 +00:00
|
|
|
if (e.keyCode === 13) {
|
2014-02-11 14:05:17 +00:00
|
|
|
e.preventDefault();
|
|
|
|
inputDisplayNameHandler(this.value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
|
|
|
* Creates the edit display name button.
|
|
|
|
*
|
|
|
|
* @returns the edit button
|
|
|
|
*/
|
2014-02-11 14:05:17 +00:00
|
|
|
function createEditDisplayNameButton() {
|
|
|
|
var editButton = document.createElement('a');
|
|
|
|
editButton.className = 'displayname';
|
|
|
|
editButton.innerHTML = '<i class="fa fa-pencil"></i>';
|
|
|
|
|
|
|
|
return editButton;
|
2014-02-22 13:28:28 +00:00
|
|
|
}
|
2014-03-26 10:33:46 +00:00
|
|
|
|
2014-04-07 10:16:49 +00:00
|
|
|
/**
|
|
|
|
* Shows audio muted indicator over small videos.
|
|
|
|
*/
|
|
|
|
function showAudioIndicator(videoSpanId, isMuted) {
|
|
|
|
var audioMutedSpan = $('#' + videoSpanId + '>span.audioMuted');
|
|
|
|
|
|
|
|
if (isMuted === 'false') {
|
|
|
|
if (audioMutedSpan.length > 0) {
|
|
|
|
audioMutedSpan.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var videoMutedSpan = $('#' + videoSpanId + '>span.videoMuted');
|
|
|
|
|
|
|
|
audioMutedSpan = document.createElement('span');
|
|
|
|
audioMutedSpan.className = 'audioMuted';
|
|
|
|
if (videoMutedSpan) {
|
|
|
|
audioMutedSpan.right = '30px';
|
|
|
|
}
|
|
|
|
$('#' + videoSpanId)[0].appendChild(audioMutedSpan);
|
|
|
|
|
|
|
|
var mutedIndicator = document.createElement('i');
|
|
|
|
mutedIndicator.className = 'icon-mic-disabled';
|
|
|
|
mutedIndicator.title = "Participant is muted";
|
|
|
|
audioMutedSpan.appendChild(mutedIndicator);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows video muted indicator over small videos.
|
|
|
|
*/
|
|
|
|
function showVideoIndicator(videoSpanId, isMuted) {
|
|
|
|
var videoMutedSpan = $('#' + videoSpanId + '>span.videoMuted');
|
|
|
|
|
|
|
|
if (isMuted === 'false') {
|
|
|
|
if (videoMutedSpan.length > 0) {
|
|
|
|
videoMutedSpan.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var audioMutedSpan = $('#' + videoSpanId + '>span.audioMuted');
|
|
|
|
|
|
|
|
videoMutedSpan = document.createElement('span');
|
|
|
|
videoMutedSpan.className = 'videoMuted';
|
|
|
|
if (audioMutedSpan) {
|
|
|
|
videoMutedSpan.right = '30px';
|
|
|
|
}
|
|
|
|
$('#' + videoSpanId)[0].appendChild(videoMutedSpan);
|
|
|
|
|
|
|
|
var mutedIndicator = document.createElement('i');
|
|
|
|
mutedIndicator.className = 'icon-camera-disabled';
|
|
|
|
mutedIndicator.title = "Participant has stopped the camera.";
|
|
|
|
videoMutedSpan.appendChild(mutedIndicator);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-26 10:33:46 +00:00
|
|
|
/**
|
|
|
|
* Resizes and repositions videos in full screen mode.
|
|
|
|
*/
|
|
|
|
$(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange',
|
|
|
|
function() {
|
|
|
|
resizeLargeVideoContainer();
|
|
|
|
positionLarge();
|
|
|
|
isFullScreen = document.fullScreen
|
|
|
|
|| document.mozFullScreen
|
|
|
|
|| document.webkitIsFullScreen;
|
|
|
|
|
|
|
|
if (isFullScreen) {
|
|
|
|
setView("fullscreen");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
setView("default");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the current view.
|
|
|
|
*/
|
|
|
|
function setView(viewName) {
|
|
|
|
// if (viewName == "fullscreen") {
|
|
|
|
// document.getElementById('videolayout_fullscreen').disabled = false;
|
|
|
|
// document.getElementById('videolayout_default').disabled = true;
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// document.getElementById('videolayout_default').disabled = false;
|
|
|
|
// document.getElementById('videolayout_fullscreen').disabled = true;
|
|
|
|
// }
|
2014-04-07 09:51:33 +00:00
|
|
|
}
|