Merge pull request #573 from damencho/shared-video-updates

Shared video updates
This commit is contained in:
yanas 2016-03-31 14:31:57 -05:00
commit b7cc03df26
5 changed files with 46 additions and 24 deletions

View File

@ -1110,7 +1110,7 @@ export default {
Commands.SHARED_VIDEO, ({value, attributes}, id) => { Commands.SHARED_VIDEO, ({value, attributes}, id) => {
if (attributes.state === 'stop') { if (attributes.state === 'stop') {
APP.UI.stopSharedVideo(id); APP.UI.stopSharedVideo(id, attributes);
} else if (attributes.state === 'start') { } else if (attributes.state === 'start') {
APP.UI.showSharedVideo(id, value, attributes); APP.UI.showSharedVideo(id, value, attributes);
} else if (attributes.state === 'playing' } else if (attributes.state === 'playing'

View File

@ -126,7 +126,7 @@
<span id="unreadMessages"></span> <span id="unreadMessages"></span>
</a> </a>
<a class="button icon-share-doc" id="toolbar_button_etherpad" data-container="body" data-toggle="popover" data-placement="bottom" content="Shared document" data-i18n="[content]toolbar.etherpad"></a> <a class="button icon-share-doc" id="toolbar_button_etherpad" data-container="body" data-toggle="popover" data-placement="bottom" content="Shared document" data-i18n="[content]toolbar.etherpad"></a>
<a class="button fa fa-share-alt-square" id="toolbar_button_sharedvideo" data-container="body" data-toggle="popover" data-placement="bottom" content="Shared Video" data-i18n="[content]toolbar.sharedvideo" style="display: none"></a> <a class="button fa fa-share-alt-square" id="toolbar_button_sharedvideo" data-container="body" data-toggle="popover" data-placement="bottom" content="Share a YouTube video" data-i18n="[content]toolbar.sharedvideo" style="display: none"></a>
<a class="button icon-share-desktop" id="toolbar_button_desktopsharing" data-container="body" data-toggle="popover" data-placement="bottom" shortcut="toggleDesktopSharingPopover" content="Share screen" data-i18n="[content]toolbar.sharescreen" style="display: none"></a> <a class="button icon-share-desktop" id="toolbar_button_desktopsharing" data-container="body" data-toggle="popover" data-placement="bottom" shortcut="toggleDesktopSharingPopover" content="Share screen" data-i18n="[content]toolbar.sharescreen" style="display: none"></a>
<a class="button icon-full-screen" id="toolbar_button_fullScreen" data-container="body" data-toggle="popover" data-placement="bottom" content="Enter / Exit Full Screen" data-i18n="[content]toolbar.fullscreen"></a> <a class="button icon-full-screen" id="toolbar_button_fullScreen" data-container="body" data-toggle="popover" data-placement="bottom" content="Enter / Exit Full Screen" data-i18n="[content]toolbar.fullscreen"></a>
<a class="button icon-telephone" id="toolbar_button_sip" data-container="body" data-toggle="popover" data-placement="bottom" content="Call SIP number" data-i18n="[content]toolbar.sip" style="display: none"></a> <a class="button icon-telephone" id="toolbar_button_sip" data-container="body" data-toggle="popover" data-placement="bottom" content="Call SIP number" data-i18n="[content]toolbar.sip" style="display: none"></a>

View File

@ -55,7 +55,7 @@
"invite": "Invite others", "invite": "Invite others",
"chat": "Open / close chat", "chat": "Open / close chat",
"etherpad": "Shared document", "etherpad": "Shared document",
"sharedvideo": "Shared video", "sharedvideo": "Share a YouTube video",
"sharescreen": "Share screen", "sharescreen": "Share screen",
"fullscreen": "Enter / Exit Full Screen", "fullscreen": "Enter / Exit Full Screen",
"sip": "Call SIP number", "sip": "Call SIP number",

View File

@ -1115,7 +1115,7 @@ UI.updateSharedVideo = function (id, url, attributes) {
*/ */
UI.stopSharedVideo = function (id, attributes) { UI.stopSharedVideo = function (id, attributes) {
if (sharedVideoManager) if (sharedVideoManager)
sharedVideoManager.stopSharedVideo(id); sharedVideoManager.stopSharedVideo(id, attributes);
}; };
module.exports = UI; module.exports = UI;

View File

@ -44,7 +44,8 @@ export default class SharedVideoManager {
if(APP.conference.isLocalId(this.from)) { if(APP.conference.isLocalId(this.from)) {
showStopVideoPropmpt().then(() => showStopVideoPropmpt().then(() =>
this.emitter.emit(UIEvents.UPDATE_SHARED_VIDEO, null, 'stop')); this.emitter.emit(
UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop'));
} else { } else {
messageHandler.openMessageDialog( messageHandler.openMessageDialog(
"dialog.shareVideoTitle", "dialog.shareVideoTitle",
@ -64,6 +65,8 @@ export default class SharedVideoManager {
if (this.isSharedVideoShown) if (this.isSharedVideoShown)
return; return;
this.isSharedVideoShown = true;
// the video url // the video url
this.url = url; this.url = url;
@ -82,7 +85,7 @@ export default class SharedVideoManager {
// we need to operate with player after start playing // we need to operate with player after start playing
// self.player will be defined once it start playing // self.player will be defined once it start playing
// and will process any initial attributes if any // and will process any initial attributes if any
this.initialAttributes = null; this.initialAttributes = attributes;
var self = this; var self = this;
if(self.isPlayerAPILoaded) if(self.isPlayerAPILoaded)
@ -148,8 +151,6 @@ export default class SharedVideoManager {
SHARED_VIDEO_CONTAINER_TYPE, self.sharedVideo); SHARED_VIDEO_CONTAINER_TYPE, self.sharedVideo);
VideoLayout.handleVideoThumbClicked(self.url); VideoLayout.handleVideoThumbClicked(self.url);
self.isSharedVideoShown = true;
// If we are sending the command and we are starting the player // If we are sending the command and we are starting the player
// we need to continuously send the player current time position // we need to continuously send the player current time position
if(APP.conference.isLocalId(self.from)) { if(APP.conference.isLocalId(self.from)) {
@ -157,17 +158,12 @@ export default class SharedVideoManager {
self.updateCheck.bind(self), self.updateCheck.bind(self),
updateInterval); updateInterval);
} }
if(self.player)
self.processAttributes(
self.player, attributes, self.playerPaused);
else {
self.initialAttributes = attributes;
}
}; };
window.onPlayerError = function(event) { window.onPlayerError = function(event) {
console.error("Error in the player:" + event.data); console.error("Error in the player:", event.data);
// store the error player, so we can remove it
self.errorInPlayer = event.target;
}; };
} }
@ -184,7 +180,7 @@ export default class SharedVideoManager {
if (attributes.state == 'playing') { if (attributes.state == 'playing') {
this.processTime(player, attributes); this.processTime(player, attributes, playerPaused);
// lets check the volume // lets check the volume
if (attributes.volume !== undefined && if (attributes.volume !== undefined &&
@ -200,7 +196,9 @@ export default class SharedVideoManager {
// if its not paused, pause it // if its not paused, pause it
player.pauseVideo(); player.pauseVideo();
this.processTime(player, attributes); this.processTime(player, attributes, !playerPaused);
} else if (attributes.state == 'stop') {
this.stopSharedVideo(this.from);
} }
} }
@ -208,9 +206,15 @@ export default class SharedVideoManager {
* Check for time in attributes and if needed seek in current player * Check for time in attributes and if needed seek in current player
* @param player the player to operate over * @param player the player to operate over
* @param attributes the attributes with the player state we want * @param attributes the attributes with the player state we want
* @param forceSeek whether seek should be forced
*/ */
processTime (player, attributes) processTime (player, attributes, forceSeek)
{ {
if(forceSeek) {
player.seekTo(attributes.time);
return;
}
// check received time and current time // check received time and current time
let currentPosition = player.getCurrentTime(); let currentPosition = player.getCurrentTime();
let diff = Math.abs(attributes.time - currentPosition); let diff = Math.abs(attributes.time - currentPosition);
@ -230,8 +234,10 @@ export default class SharedVideoManager {
updateCheck(sendPauseEvent) updateCheck(sendPauseEvent)
{ {
// ignore update checks if we are not the owner of the video // ignore update checks if we are not the owner of the video
// or there is still no player defined // or there is still no player defined or we are stopped
if(!APP.conference.isLocalId(this.from) || !this.player) // (in a process of stopping)
if(!APP.conference.isLocalId(this.from) || !this.player
|| !this.isSharedVideoShown)
return; return;
let state = this.player.getPlayerState(); let state = this.player.getPlayerState();
@ -281,13 +287,22 @@ export default class SharedVideoManager {
* left and we want to remove video if the user sharing it left). * left and we want to remove video if the user sharing it left).
* @param id the id of the sender of the command * @param id the id of the sender of the command
*/ */
stopSharedVideo (id) { stopSharedVideo (id, attributes) {
if (!this.isSharedVideoShown) if (!this.isSharedVideoShown)
return; return;
if(this.from !== id) if(this.from !== id)
return; return;
if(!this.player){
// if there is no error in the player till now,
// store the initial attributes
if (!this.errorInPlayer) {
this.initialAttributes = attributes;
return;
}
}
if(this.intervalId) { if(this.intervalId) {
clearInterval(this.intervalId); clearInterval(this.intervalId);
this.intervalId = null; this.intervalId = null;
@ -300,12 +315,19 @@ export default class SharedVideoManager {
VideoLayout.removeLargeVideoContainer( VideoLayout.removeLargeVideoContainer(
SHARED_VIDEO_CONTAINER_TYPE); SHARED_VIDEO_CONTAINER_TYPE);
if(this.player) {
this.player.destroy(); this.player.destroy();
this.player = null; this.player = null;
}//
else if (this.errorInPlayer) {
this.errorInPlayer.destroy();
this.errorInPlayer = null;
}
}); });
this.url = null; this.url = null;
this.isSharedVideoShown = false; this.isSharedVideoShown = false;
this.initialAttributes = null;
} }
} }