From f0a82827369059fb35666f60e6fa03589235d0fa Mon Sep 17 00:00:00 2001 From: yanas Date: Fri, 30 May 2014 17:18:32 +0200 Subject: [PATCH] Fixes some problems related to adding a prezi to the conference. Updates the Prezi Player and fixes some issues caused by commit 76c0485e (Skip animation steps). --- app.js | 9 +++++++-- libs/prezi_player.js | 36 ++++++++++++++++++++++++++++++++++-- muc.js | 1 + prezi.js | 14 +++++++++----- 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/app.js b/app.js index d81048cb3..d7bfe35d4 100644 --- a/app.js +++ b/app.js @@ -858,6 +858,8 @@ function toggleVideo() { function toggleAudio() { if (!(connection && connection.jingle.localAudio)) { preMuted = true; + // We still click the button. + buttonClick("#mute", "icon-microphone icon-mic-disabled"); return; } @@ -866,7 +868,8 @@ function toggleAudio() { var audioEnabled = localAudio.getAudioTracks()[idx].enabled; localAudio.getAudioTracks()[idx].enabled = !audioEnabled; - connection.emuc.addAudioInfoToPresence(audioEnabled); //isMuted is the opposite of audioEnabled + // isMuted is the opposite of audioEnabled + connection.emuc.addAudioInfoToPresence(audioEnabled); connection.emuc.sendPresence(); } @@ -1569,7 +1572,9 @@ function addRemoteVideoContainer(peerJid, spanId) { container.className = 'videocontainer'; var remotes = document.getElementById('remoteVideos'); - if (focus) + // If the peerJid is null then this video span couldn't be directly + // associated with a participant (this could happen in the case of prezi). + if (focus && peerJid != null) addRemoteVideoMenu(peerJid, container); remotes.appendChild(container); diff --git a/libs/prezi_player.js b/libs/prezi_player.js index 48b4c8b59..ba34a18c3 100644 --- a/libs/prezi_player.js +++ b/libs/prezi_player.js @@ -6,11 +6,13 @@ PreziPlayer.API_VERSION = 1; PreziPlayer.CURRENT_STEP = 'currentStep'; + PreziPlayer.CURRENT_ANIMATION_STEP = 'currentAnimationStep'; PreziPlayer.CURRENT_OBJECT = 'currentObject'; PreziPlayer.STATUS_LOADING = 'loading'; PreziPlayer.STATUS_READY = 'ready'; PreziPlayer.STATUS_CONTENT_READY = 'contentready'; PreziPlayer.EVENT_CURRENT_STEP = "currentStepChange"; + PreziPlayer.EVENT_CURRENT_ANIMATION_STEP = "currentAnimationStepChange"; PreziPlayer.EVENT_CURRENT_OBJECT = "currentObjectChange"; PreziPlayer.EVENT_STATUS = "statusChange"; PreziPlayer.EVENT_PLAYING = "isAutoPlayingChange"; @@ -61,6 +63,7 @@ this.options = options; this.values = {'status': PreziPlayer.STATUS_LOADING}; this.values[PreziPlayer.CURRENT_STEP] = 0; + this.values[PreziPlayer.CURRENT_ANIMATION_STEP] = 0; this.values[PreziPlayer.CURRENT_OBJECT] = null; this.callbacks = []; this.id = id; @@ -84,14 +87,16 @@ this.iframe.width = options.width || 640; this.iframe.height = options.height || 480; this.embedTo.innerHTML = ''; + // JITSI: IN CASE SOMETHING GOES WRONG. try { this.embedTo.appendChild(this.iframe); } catch (err) { console.log("CATCH ERROR"); } - + // JITSI: Increase interval from 200 to 500, which fixes prezi + // crashes for us. this.initPollInterval = setInterval(function(){ _this.sendMessage({'action': 'init'}); }, 500); @@ -152,7 +157,26 @@ }; PreziPlayer.prototype.toStep = /* toStep is DEPRECATED */ - PreziPlayer.prototype.flyToStep = function(step) { + PreziPlayer.prototype.flyToStep = function(step, animation_step) { + var obj = this; + // check animation_step + if (animation_step > 0 && + obj.values.animationCountOnSteps && + obj.values.animationCountOnSteps[step] <= animation_step) { + animation_step = obj.values.animationCountOnSteps[step]; + } + // jump to animation steps by calling flyToNextStep() + function doAnimationSteps() { + if (obj.values.isMoving == true) { + setTimeout(doAnimationSteps, 100); // wait until the flight ends + return; + } + while (animation_step-- > 0) { + obj.flyToNextStep(); // do the animation steps + } + } + setTimeout(doAnimationSteps, 200); // 200ms is the internal "reporting" time + // jump to the step return this.sendMessage({ 'action': 'present', 'data': ['moveToStep', step] @@ -192,6 +216,10 @@ return this.values.currentStep; }; + PreziPlayer.prototype.getCurrentAnimationStep = function() { + return this.values.currentAnimationStep; + }; + PreziPlayer.prototype.getCurrentObject = function() { return this.values.currentObject; }; @@ -208,6 +236,10 @@ return this.values.stepCount; }; + PreziPlayer.prototype.getAnimationCountOnSteps = function() { + return this.values.animationCountOnSteps; + }; + PreziPlayer.prototype.getTitle = function() { return this.values.title; }; diff --git a/muc.js b/muc.js index c5f21b614..dee2474a9 100644 --- a/muc.js +++ b/muc.js @@ -61,6 +61,7 @@ Strophe.addConnectionPlugin('emuc', { { var url = presentation.attr('url'); var current = presentation.find('>current').text(); + console.log('presentation info received from', from, url); if (this.preziMap[from] == null) { diff --git a/prezi.js b/prezi.js index 85506ae5e..8de0688d6 100644 --- a/prezi.js +++ b/prezi.js @@ -169,11 +169,15 @@ var Prezi = (function (my) { console.log("presentation added", presUrl); var presId = getPresentationId(presUrl); + var elementId = 'participant_' + Strophe.getResourceFromJid(jid) + '_' + presId; - addRemoteVideoContainer(elementId); + // We explicitly don't specify the peer jid here, because we don't want + // this video to be dealt with as a peer related one (for example we + // don't want to show a mute/kick menu for this one, etc.). + addRemoteVideoContainer(null, elementId); resizeThumbnails(); var controlsEnabled = false; @@ -322,12 +326,12 @@ var Prezi = (function (my) { * Indicates presentation slide change. */ $(document).bind('gotoslide.muc', function (event, jid, presUrl, current) { - if (preziPlayer) { + if (preziPlayer && preziPlayer.getCurrentStep() != current) { preziPlayer.flyToStep(current); - // + var animationStepsArray = preziPlayer.getAnimationCountOnSteps(); - for (var i = 0; i <= animationStepsArray[current]; i++) { - preziPlayer.flyToNextStep(); + for (var i = 0; i < parseInt(animationStepsArray[current]); i++) { + preziPlayer.flyToStep(current, i); } } });