2017-06-14 23:52:59 +00:00
|
|
|
/* global $, APP, YT, interfaceConfig, onPlayerReady, onPlayerStateChange,
|
|
|
|
onPlayerError */
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
2016-03-18 20:00:55 +00:00
|
|
|
|
|
|
|
import UIUtil from '../util/UIUtil';
|
|
|
|
import UIEvents from '../../../service/UI/UIEvents';
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
import VideoLayout from '../videolayout/VideoLayout';
|
2016-03-18 20:00:55 +00:00
|
|
|
import LargeContainer from '../videolayout/LargeContainer';
|
2017-04-10 17:59:44 +00:00
|
|
|
import Filmstrip from '../videolayout/Filmstrip';
|
2017-02-16 23:02:40 +00:00
|
|
|
|
2017-12-11 18:48:32 +00:00
|
|
|
import {
|
2018-01-03 21:24:07 +00:00
|
|
|
createSharedVideoEvent as createEvent,
|
|
|
|
sendAnalytics
|
2017-12-11 18:48:32 +00:00
|
|
|
} from '../../../react/features/analytics';
|
2017-06-27 22:56:55 +00:00
|
|
|
import {
|
|
|
|
participantJoined,
|
2018-05-22 17:13:51 +00:00
|
|
|
participantLeft,
|
|
|
|
pinParticipant
|
2017-06-27 22:56:55 +00:00
|
|
|
} from '../../../react/features/base/participants';
|
2018-03-07 00:28:19 +00:00
|
|
|
import {
|
|
|
|
dockToolbox,
|
|
|
|
getToolboxHeight,
|
|
|
|
showToolbox
|
|
|
|
} from '../../../react/features/toolbox';
|
2016-03-18 20:00:55 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
export const SHARED_VIDEO_CONTAINER_TYPE = 'sharedvideo';
|
2016-03-18 20:00:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Example shared video link.
|
|
|
|
* @type {string}
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
const defaultSharedVideoLink = 'https://www.youtube.com/watch?v=xNXN7CZk8X0';
|
2016-03-25 20:36:41 +00:00
|
|
|
const updateInterval = 5000; // milliseconds
|
2016-07-06 18:26:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The dialog for user input (video link).
|
|
|
|
* @type {null}
|
|
|
|
*/
|
|
|
|
let dialog = null;
|
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
/**
|
|
|
|
* Manager of shared video.
|
|
|
|
*/
|
|
|
|
export default class SharedVideoManager {
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
constructor(emitter) {
|
2016-03-18 20:00:55 +00:00
|
|
|
this.emitter = emitter;
|
|
|
|
this.isSharedVideoShown = false;
|
|
|
|
this.isPlayerAPILoaded = false;
|
2016-04-19 18:07:04 +00:00
|
|
|
this.mutedWithUserInteraction = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-04-25 20:39:31 +00:00
|
|
|
* Indicates if the player volume is currently on. This will return true if
|
|
|
|
* we have an available player, which is currently in a PLAYING state,
|
|
|
|
* which isn't muted and has it's volume greater than 0.
|
2016-04-19 18:07:04 +00:00
|
|
|
*
|
2016-04-25 20:39:31 +00:00
|
|
|
* @returns {boolean} indicating if the volume of the shared video is
|
|
|
|
* currently on.
|
2016-04-19 18:07:04 +00:00
|
|
|
*/
|
|
|
|
isSharedVideoVolumeOn() {
|
2017-10-12 23:02:29 +00:00
|
|
|
return this.player
|
2016-04-25 20:39:31 +00:00
|
|
|
&& this.player.getPlayerState() === YT.PlayerState.PLAYING
|
|
|
|
&& !this.player.isMuted()
|
2017-10-12 23:02:29 +00:00
|
|
|
&& this.player.getVolume() > 0;
|
2016-04-19 18:07:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates if the local user is the owner of the shared video.
|
|
|
|
* @returns {*|boolean}
|
|
|
|
*/
|
|
|
|
isSharedVideoOwner() {
|
|
|
|
return this.from && APP.conference.isLocalId(this.from);
|
2016-03-18 20:00:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts shared video by asking user for url, or if its already working
|
|
|
|
* asks whether the user wants to stop sharing the video.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
toggleSharedVideo() {
|
|
|
|
if (dialog) {
|
2016-07-06 18:26:27 +00:00
|
|
|
return;
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
2016-07-06 18:26:27 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
if (!this.isSharedVideoShown) {
|
2016-03-18 20:00:55 +00:00
|
|
|
requestVideoLink().then(
|
2016-08-04 19:19:09 +00:00
|
|
|
url => {
|
|
|
|
this.emitter.emit(
|
|
|
|
UIEvents.UPDATE_SHARED_VIDEO, url, 'start');
|
2018-01-03 21:24:07 +00:00
|
|
|
sendAnalytics(createEvent('started'));
|
2016-08-04 19:19:09 +00:00
|
|
|
},
|
|
|
|
err => {
|
2016-11-11 15:00:54 +00:00
|
|
|
logger.log('SHARED VIDEO CANCELED', err);
|
2018-01-03 21:24:07 +00:00
|
|
|
sendAnalytics(createEvent('canceled'));
|
2016-08-04 19:19:09 +00:00
|
|
|
}
|
2016-03-18 20:00:55 +00:00
|
|
|
);
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
if (APP.conference.isLocalId(this.from)) {
|
2017-10-02 23:08:07 +00:00
|
|
|
showStopVideoPropmpt().then(
|
|
|
|
() => {
|
2016-11-09 18:42:47 +00:00
|
|
|
// make sure we stop updates for playing before we send stop
|
|
|
|
// if we stop it after receiving self presence, we can end
|
|
|
|
// up sending stop playing, and on the other end it will not
|
|
|
|
// stop
|
2017-10-02 23:08:07 +00:00
|
|
|
if (this.intervalId) {
|
|
|
|
clearInterval(this.intervalId);
|
|
|
|
this.intervalId = null;
|
2016-11-09 18:42:47 +00:00
|
|
|
}
|
2016-08-04 19:19:09 +00:00
|
|
|
this.emitter.emit(
|
|
|
|
UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop');
|
2018-01-03 21:24:07 +00:00
|
|
|
sendAnalytics(createEvent('stopped'));
|
2016-08-04 19:19:09 +00:00
|
|
|
},
|
2017-10-12 23:02:29 +00:00
|
|
|
() => {}); // eslint-disable-line no-empty-function
|
2016-03-26 00:38:56 +00:00
|
|
|
} else {
|
2017-11-03 19:05:03 +00:00
|
|
|
APP.UI.messageHandler.showWarning({
|
|
|
|
descriptionKey: 'dialog.alreadySharedVideoMsg',
|
|
|
|
titleKey: 'dialog.alreadySharedVideoTitle'
|
|
|
|
});
|
2018-01-03 21:24:07 +00:00
|
|
|
sendAnalytics(createEvent('already.shared'));
|
2016-03-26 00:38:56 +00:00
|
|
|
}
|
2016-03-18 20:00:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-04-28 16:54:10 +00:00
|
|
|
* Shows the player component and starts the process that will be sending
|
|
|
|
* updates, if we are the one shared the video.
|
|
|
|
*
|
2016-03-24 20:25:26 +00:00
|
|
|
* @param id the id of the sender of the command
|
2016-03-18 20:00:55 +00:00
|
|
|
* @param url the video url
|
|
|
|
* @param attributes
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
onSharedVideoStart(id, url, attributes) {
|
|
|
|
if (this.isSharedVideoShown) {
|
2016-03-18 20:00:55 +00:00
|
|
|
return;
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
2016-03-18 20:00:55 +00:00
|
|
|
|
2016-03-31 02:36:05 +00:00
|
|
|
this.isSharedVideoShown = true;
|
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
// the video url
|
|
|
|
this.url = url;
|
|
|
|
|
|
|
|
// the owner of the video
|
2016-03-24 20:25:26 +00:00
|
|
|
this.from = id;
|
2016-03-18 20:00:55 +00:00
|
|
|
|
2016-04-28 22:42:52 +00:00
|
|
|
this.mutedWithUserInteraction = APP.conference.isLocalAudioMuted();
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
// listen for local audio mute events
|
2016-04-25 20:39:31 +00:00
|
|
|
this.localAudioMutedListener = this.onLocalAudioMuted.bind(this);
|
2016-04-01 19:53:11 +00:00
|
|
|
this.emitter.on(UIEvents.AUDIO_MUTED, this.localAudioMutedListener);
|
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
// This code loads the IFrame Player API code asynchronously.
|
2017-10-12 23:02:29 +00:00
|
|
|
const tag = document.createElement('script');
|
|
|
|
|
|
|
|
tag.src = 'https://www.youtube.com/iframe_api';
|
|
|
|
const firstScriptTag = document.getElementsByTagName('script')[0];
|
2016-03-18 20:00:55 +00:00
|
|
|
|
|
|
|
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
|
|
|
|
2016-03-25 20:36:41 +00:00
|
|
|
// sometimes we receive errors like player not defined
|
|
|
|
// or player.pauseVideo is not a function
|
|
|
|
// we need to operate with player after start playing
|
|
|
|
// self.player will be defined once it start playing
|
|
|
|
// and will process any initial attributes if any
|
2016-03-31 17:14:45 +00:00
|
|
|
this.initialAttributes = attributes;
|
2016-03-25 20:36:41 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const self = this;
|
|
|
|
|
|
|
|
if (self.isPlayerAPILoaded) {
|
2016-03-18 20:00:55 +00:00
|
|
|
window.onYouTubeIframeAPIReady();
|
2017-10-12 23:02:29 +00:00
|
|
|
} else {
|
2016-03-18 20:00:55 +00:00
|
|
|
window.onYouTubeIframeAPIReady = function() {
|
|
|
|
self.isPlayerAPILoaded = true;
|
2017-10-12 23:02:29 +00:00
|
|
|
const showControls
|
|
|
|
= APP.conference.isLocalId(self.from) ? 1 : 0;
|
|
|
|
const p = new YT.Player('sharedVideoIFrame', {
|
2016-03-18 20:00:55 +00:00
|
|
|
height: '100%',
|
|
|
|
width: '100%',
|
|
|
|
videoId: self.url,
|
|
|
|
playerVars: {
|
|
|
|
'origin': location.origin,
|
|
|
|
'fs': '0',
|
2016-03-25 20:36:41 +00:00
|
|
|
'autoplay': 0,
|
2016-03-18 20:00:55 +00:00
|
|
|
'controls': showControls,
|
2017-10-12 23:02:29 +00:00
|
|
|
'rel': 0
|
2016-03-18 20:00:55 +00:00
|
|
|
},
|
|
|
|
events: {
|
|
|
|
'onReady': onPlayerReady,
|
|
|
|
'onStateChange': onPlayerStateChange,
|
|
|
|
'onError': onPlayerError
|
|
|
|
}
|
2016-04-01 22:08:35 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// add listener for volume changes
|
|
|
|
p.addEventListener(
|
2017-10-12 23:02:29 +00:00
|
|
|
'onVolumeChange', 'onVolumeChange');
|
2016-04-01 22:08:35 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
if (APP.conference.isLocalId(self.from)) {
|
|
|
|
// adds progress listener that will be firing events
|
|
|
|
// while we are paused and we change the progress of the
|
|
|
|
// video (seeking forward or backward on the video)
|
2016-04-01 22:08:35 +00:00
|
|
|
p.addEventListener(
|
2017-10-12 23:02:29 +00:00
|
|
|
'onVideoProgress', 'onVideoProgress');
|
2016-04-01 22:08:35 +00:00
|
|
|
}
|
2016-03-18 20:00:55 +00:00
|
|
|
};
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
2016-03-18 20:00:55 +00:00
|
|
|
|
2016-04-28 16:54:10 +00:00
|
|
|
/**
|
|
|
|
* Indicates that a change in state has occurred for the shared video.
|
|
|
|
* @param event the event notifying us of the change
|
|
|
|
*/
|
2016-03-18 20:00:55 +00:00
|
|
|
window.onPlayerStateChange = function(event) {
|
2017-10-12 23:02:29 +00:00
|
|
|
// eslint-disable-next-line eqeqeq
|
2016-03-18 20:00:55 +00:00
|
|
|
if (event.data == YT.PlayerState.PLAYING) {
|
2016-03-25 20:36:41 +00:00
|
|
|
self.player = event.target;
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
if (self.initialAttributes) {
|
2016-04-28 16:54:10 +00:00
|
|
|
// If a network update has occurred already now is the
|
|
|
|
// time to process it.
|
|
|
|
self.processVideoUpdate(
|
2016-04-25 20:39:31 +00:00
|
|
|
self.player,
|
2016-04-28 16:54:10 +00:00
|
|
|
self.initialAttributes);
|
2016-04-25 20:39:31 +00:00
|
|
|
|
2016-03-25 20:36:41 +00:00
|
|
|
self.initialAttributes = null;
|
2016-03-24 03:42:17 +00:00
|
|
|
}
|
2016-04-28 16:54:10 +00:00
|
|
|
self.smartAudioMute();
|
2017-10-12 23:02:29 +00:00
|
|
|
// eslint-disable-next-line eqeqeq
|
2016-03-18 20:00:55 +00:00
|
|
|
} else if (event.data == YT.PlayerState.PAUSED) {
|
2016-04-28 16:54:10 +00:00
|
|
|
self.smartAudioUnmute();
|
2018-01-03 21:24:07 +00:00
|
|
|
sendAnalytics(createEvent('paused'));
|
2016-03-18 20:00:55 +00:00
|
|
|
}
|
2017-10-12 23:02:29 +00:00
|
|
|
// eslint-disable-next-line eqeqeq
|
2016-04-28 16:54:10 +00:00
|
|
|
self.fireSharedVideoEvent(event.data == YT.PlayerState.PAUSED);
|
2016-03-18 20:00:55 +00:00
|
|
|
};
|
|
|
|
|
2016-04-01 22:08:35 +00:00
|
|
|
/**
|
|
|
|
* Track player progress while paused.
|
|
|
|
* @param event
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
window.onVideoProgress = function(event) {
|
|
|
|
const state = event.target.getPlayerState();
|
|
|
|
|
|
|
|
// eslint-disable-next-line eqeqeq
|
2016-04-01 22:08:35 +00:00
|
|
|
if (state == YT.PlayerState.PAUSED) {
|
2016-04-28 16:54:10 +00:00
|
|
|
self.fireSharedVideoEvent(true);
|
2016-04-01 22:08:35 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-03-31 20:32:13 +00:00
|
|
|
/**
|
|
|
|
* Gets notified for volume state changed.
|
|
|
|
* @param event
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
window.onVolumeChange = function(event) {
|
2016-04-28 16:54:10 +00:00
|
|
|
self.fireSharedVideoEvent();
|
2016-04-01 19:53:11 +00:00
|
|
|
|
|
|
|
// let's check, if player is not muted lets mute locally
|
2017-10-12 23:02:29 +00:00
|
|
|
if (event.data.volume > 0 && !event.data.muted) {
|
2016-04-28 16:54:10 +00:00
|
|
|
self.smartAudioMute();
|
2017-10-12 23:02:29 +00:00
|
|
|
} else if (event.data.volume <= 0 || event.data.muted) {
|
2016-04-28 16:54:10 +00:00
|
|
|
self.smartAudioUnmute();
|
2016-04-19 18:07:04 +00:00
|
|
|
}
|
2018-01-03 21:24:07 +00:00
|
|
|
sendAnalytics(createEvent(
|
|
|
|
'volume.changed',
|
|
|
|
{
|
|
|
|
volume: event.data.volume,
|
|
|
|
muted: event.data.muted
|
|
|
|
}));
|
2016-03-31 20:32:13 +00:00
|
|
|
};
|
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
window.onPlayerReady = function(event) {
|
2017-10-12 23:02:29 +00:00
|
|
|
const player = event.target;
|
|
|
|
|
2016-03-25 20:36:41 +00:00
|
|
|
// do not relay on autoplay as it is not sending all of the events
|
|
|
|
// in onPlayerStateChange
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
player.playVideo();
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const iframe = player.getIframe();
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-use-before-define
|
2016-03-18 20:00:55 +00:00
|
|
|
self.sharedVideo = new SharedVideoContainer(
|
2017-10-12 23:02:29 +00:00
|
|
|
{ url,
|
|
|
|
iframe,
|
|
|
|
player });
|
2016-03-18 20:00:55 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
// prevents pausing participants not sharing the video
|
2016-04-01 22:23:30 +00:00
|
|
|
// to pause the video
|
|
|
|
if (!APP.conference.isLocalId(self.from)) {
|
2017-10-12 23:02:29 +00:00
|
|
|
$('#sharedVideo').css('pointer-events', 'none');
|
2016-04-01 22:23:30 +00:00
|
|
|
}
|
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
VideoLayout.addLargeVideoContainer(
|
|
|
|
SHARED_VIDEO_CONTAINER_TYPE, self.sharedVideo);
|
2017-06-27 22:56:55 +00:00
|
|
|
|
|
|
|
APP.store.dispatch(participantJoined({
|
2018-05-29 01:43:28 +00:00
|
|
|
|
|
|
|
// FIXME The cat is out of the bag already or rather _room is
|
|
|
|
// not private because it is used in multiple other places
|
|
|
|
// already such as AbstractPageReloadOverlay and
|
|
|
|
// JitsiMeetLogStorage.
|
|
|
|
conference: APP.conference._room,
|
2017-06-27 22:56:55 +00:00
|
|
|
id: self.url,
|
|
|
|
isBot: true,
|
2017-11-13 23:51:36 +00:00
|
|
|
name: 'YouTube'
|
2017-06-27 22:56:55 +00:00
|
|
|
}));
|
|
|
|
|
2018-05-22 17:13:51 +00:00
|
|
|
APP.store.dispatch(pinParticipant(self.url));
|
2016-03-18 20:00:55 +00:00
|
|
|
|
2016-03-22 19:49:37 +00:00
|
|
|
// If we are sending the command and we are starting the player
|
|
|
|
// we need to continuously send the player current time position
|
2017-10-12 23:02:29 +00:00
|
|
|
if (APP.conference.isLocalId(self.from)) {
|
2016-03-18 20:00:55 +00:00
|
|
|
self.intervalId = setInterval(
|
2016-04-28 16:54:10 +00:00
|
|
|
self.fireSharedVideoEvent.bind(self),
|
2016-03-25 20:36:41 +00:00
|
|
|
updateInterval);
|
2016-03-18 20:00:55 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
window.onPlayerError = function(event) {
|
2017-10-12 23:02:29 +00:00
|
|
|
logger.error('Error in the player:', event.data);
|
|
|
|
|
2016-03-31 19:11:33 +00:00
|
|
|
// store the error player, so we can remove it
|
|
|
|
self.errorInPlayer = event.target;
|
2016-03-18 20:00:55 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-03-25 20:36:41 +00:00
|
|
|
/**
|
|
|
|
* Process attributes, whether player needs to be paused or seek.
|
|
|
|
* @param player the player to operate over
|
|
|
|
* @param attributes the attributes with the player state we want
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
processVideoUpdate(player, attributes) {
|
|
|
|
if (!attributes) {
|
2016-03-25 20:36:41 +00:00
|
|
|
return;
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
2016-03-25 20:36:41 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
// eslint-disable-next-line eqeqeq
|
2016-03-25 20:36:41 +00:00
|
|
|
if (attributes.state == 'playing') {
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const isPlayerPaused
|
|
|
|
= this.player.getPlayerState() === YT.PlayerState.PAUSED;
|
2016-03-25 20:36:41 +00:00
|
|
|
|
2016-04-28 16:54:10 +00:00
|
|
|
// If our player is currently paused force the seek.
|
|
|
|
this.processTime(player, attributes, isPlayerPaused);
|
2016-04-25 20:39:31 +00:00
|
|
|
|
2016-04-28 16:54:10 +00:00
|
|
|
// Process mute.
|
2017-10-12 23:02:29 +00:00
|
|
|
const isAttrMuted = attributes.muted === 'true';
|
|
|
|
|
2016-04-28 16:54:10 +00:00
|
|
|
if (player.isMuted() !== isAttrMuted) {
|
|
|
|
this.smartPlayerMute(isAttrMuted, true);
|
2016-04-25 20:39:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Process volume
|
|
|
|
if (!isAttrMuted
|
|
|
|
&& attributes.volume !== undefined
|
2017-10-12 23:02:29 +00:00
|
|
|
// eslint-disable-next-line eqeqeq
|
2016-04-25 20:39:31 +00:00
|
|
|
&& player.getVolume() != attributes.volume) {
|
2016-04-19 18:07:04 +00:00
|
|
|
|
2016-03-25 20:36:41 +00:00
|
|
|
player.setVolume(attributes.volume);
|
2017-10-12 23:02:29 +00:00
|
|
|
logger.info(`Player change of volume:${attributes.volume}`);
|
2016-03-25 20:36:41 +00:00
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
if (isPlayerPaused) {
|
2016-03-25 20:36:41 +00:00
|
|
|
player.playVideo();
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
|
|
|
// eslint-disable-next-line eqeqeq
|
2016-03-25 20:36:41 +00:00
|
|
|
} else if (attributes.state == 'pause') {
|
|
|
|
// if its not paused, pause it
|
|
|
|
player.pauseVideo();
|
2016-03-27 20:32:45 +00:00
|
|
|
|
2016-04-01 22:08:35 +00:00
|
|
|
this.processTime(player, attributes, true);
|
2016-03-27 20:32:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check for time in attributes and if needed seek in current player
|
|
|
|
* @param player the player to operate over
|
|
|
|
* @param attributes the attributes with the player state we want
|
2016-03-31 05:07:12 +00:00
|
|
|
* @param forceSeek whether seek should be forced
|
2016-03-27 20:32:45 +00:00
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
processTime(player, attributes, forceSeek) {
|
|
|
|
if (forceSeek) {
|
|
|
|
logger.info('Player seekTo:', attributes.time);
|
2016-03-31 05:07:12 +00:00
|
|
|
player.seekTo(attributes.time);
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-03-31 05:07:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-27 20:32:45 +00:00
|
|
|
// check received time and current time
|
2017-10-12 23:02:29 +00:00
|
|
|
const currentPosition = player.getCurrentTime();
|
|
|
|
const diff = Math.abs(attributes.time - currentPosition);
|
2016-03-27 20:32:45 +00:00
|
|
|
|
|
|
|
// if we drift more than the interval for checking
|
|
|
|
// sync, the interval is in milliseconds
|
2017-10-12 23:02:29 +00:00
|
|
|
if (diff > updateInterval / 1000) {
|
|
|
|
logger.info('Player seekTo:', attributes.time,
|
|
|
|
' current time is:', currentPosition, ' diff:', diff);
|
2016-03-27 20:32:45 +00:00
|
|
|
player.seekTo(attributes.time);
|
2016-03-25 20:36:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
/**
|
|
|
|
* Checks current state of the player and fire an event with the values.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
fireSharedVideoEvent(sendPauseEvent) {
|
2016-03-18 20:00:55 +00:00
|
|
|
// ignore update checks if we are not the owner of the video
|
2016-03-31 17:14:45 +00:00
|
|
|
// or there is still no player defined or we are stopped
|
|
|
|
// (in a process of stopping)
|
2017-10-12 23:02:29 +00:00
|
|
|
if (!APP.conference.isLocalId(this.from) || !this.player
|
|
|
|
|| !this.isSharedVideoShown) {
|
2016-03-18 20:00:55 +00:00
|
|
|
return;
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const state = this.player.getPlayerState();
|
2016-03-18 20:00:55 +00:00
|
|
|
|
|
|
|
// if its paused and haven't been pause - send paused
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-03-18 21:47:47 +00:00
|
|
|
if (state === YT.PlayerState.PAUSED && sendPauseEvent) {
|
2016-03-18 20:00:55 +00:00
|
|
|
this.emitter.emit(UIEvents.UPDATE_SHARED_VIDEO,
|
2016-03-27 20:32:45 +00:00
|
|
|
this.url, 'pause', this.player.getCurrentTime());
|
2017-10-12 23:02:29 +00:00
|
|
|
} else if (state === YT.PlayerState.PLAYING) {
|
|
|
|
// if its playing and it was paused - send update with time
|
|
|
|
// if its playing and was playing just send update with time
|
2016-03-18 20:00:55 +00:00
|
|
|
this.emitter.emit(UIEvents.UPDATE_SHARED_VIDEO,
|
|
|
|
this.url, 'playing',
|
|
|
|
this.player.getCurrentTime(),
|
2016-04-25 20:39:31 +00:00
|
|
|
this.player.isMuted(),
|
|
|
|
this.player.getVolume());
|
2016-03-18 20:00:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-01-03 21:24:07 +00:00
|
|
|
* Updates video, if it's not playing and needs starting or if it's playing
|
|
|
|
* and needs to be paused.
|
2016-03-24 20:25:26 +00:00
|
|
|
* @param id the id of the sender of the command
|
2016-03-18 20:00:55 +00:00
|
|
|
* @param url the video url
|
|
|
|
* @param attributes
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
onSharedVideoUpdate(id, url, attributes) {
|
2016-03-18 20:00:55 +00:00
|
|
|
// if we are sending the event ignore
|
2017-10-12 23:02:29 +00:00
|
|
|
if (APP.conference.isLocalId(this.from)) {
|
2016-03-18 20:00:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
if (!this.isSharedVideoShown) {
|
2016-04-28 16:54:10 +00:00
|
|
|
this.onSharedVideoStart(id, url, attributes);
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-03-25 20:36:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-03-18 20:00:55 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
// eslint-disable-next-line no-negated-condition
|
|
|
|
if (!this.player) {
|
2016-03-25 20:36:41 +00:00
|
|
|
this.initialAttributes = attributes;
|
2017-10-12 23:02:29 +00:00
|
|
|
} else {
|
2016-04-28 16:54:10 +00:00
|
|
|
this.processVideoUpdate(this.player, attributes);
|
2016-03-18 20:00:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop shared video if it is currently showed. If the user started the
|
2016-03-24 20:25:26 +00:00
|
|
|
* shared video is the one in the id (called when user
|
2016-03-18 20:00:55 +00:00
|
|
|
* left and we want to remove video if the user sharing it left).
|
2016-03-24 20:25:26 +00:00
|
|
|
* @param id the id of the sender of the command
|
2016-03-18 20:00:55 +00:00
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
onSharedVideoStop(id, attributes) {
|
|
|
|
if (!this.isSharedVideoShown) {
|
2016-03-18 20:00:55 +00:00
|
|
|
return;
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
2016-03-18 20:00:55 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
if (this.from !== id) {
|
2016-03-18 20:00:55 +00:00
|
|
|
return;
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
2016-03-18 20:00:55 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
if (!this.player) {
|
2016-03-31 19:11:33 +00:00
|
|
|
// if there is no error in the player till now,
|
|
|
|
// store the initial attributes
|
|
|
|
if (!this.errorInPlayer) {
|
|
|
|
this.initialAttributes = attributes;
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-03-31 19:11:33 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-03-31 17:14:45 +00:00
|
|
|
}
|
|
|
|
|
2016-04-01 19:53:11 +00:00
|
|
|
this.emitter.removeListener(UIEvents.AUDIO_MUTED,
|
|
|
|
this.localAudioMutedListener);
|
|
|
|
this.localAudioMutedListener = null;
|
|
|
|
|
2018-05-21 21:22:41 +00:00
|
|
|
APP.store.dispatch(participantLeft(this.url, APP.conference._room));
|
2016-03-18 20:00:55 +00:00
|
|
|
|
|
|
|
VideoLayout.showLargeVideoContainer(SHARED_VIDEO_CONTAINER_TYPE, false)
|
|
|
|
.then(() => {
|
|
|
|
VideoLayout.removeLargeVideoContainer(
|
|
|
|
SHARED_VIDEO_CONTAINER_TYPE);
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
if (this.player) {
|
2016-03-31 19:11:33 +00:00
|
|
|
this.player.destroy();
|
|
|
|
this.player = null;
|
2017-10-12 23:02:29 +00:00
|
|
|
} else if (this.errorInPlayer) {
|
|
|
|
// if there is an error in player, remove that instance
|
2016-03-31 19:11:33 +00:00
|
|
|
this.errorInPlayer.destroy();
|
|
|
|
this.errorInPlayer = null;
|
|
|
|
}
|
2016-04-28 16:54:10 +00:00
|
|
|
this.smartAudioUnmute();
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-04-01 22:23:30 +00:00
|
|
|
// revert to original behavior (prevents pausing
|
|
|
|
// for participants not sharing the video to pause it)
|
2017-10-12 23:02:29 +00:00
|
|
|
$('#sharedVideo').css('pointer-events', 'auto');
|
2017-05-19 00:40:14 +00:00
|
|
|
|
|
|
|
this.emitter.emit(
|
|
|
|
UIEvents.UPDATE_SHARED_VIDEO, null, 'removed');
|
2017-10-02 23:08:07 +00:00
|
|
|
});
|
2016-03-18 20:00:55 +00:00
|
|
|
|
|
|
|
this.url = null;
|
|
|
|
this.isSharedVideoShown = false;
|
2016-03-31 19:11:33 +00:00
|
|
|
this.initialAttributes = null;
|
2016-03-18 20:00:55 +00:00
|
|
|
}
|
2016-04-01 19:53:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Receives events for local audio mute/unmute by local user.
|
|
|
|
* @param muted boolena whether it is muted or not.
|
2016-04-19 18:07:04 +00:00
|
|
|
* @param {boolean} indicates if this mute was a result of user interaction,
|
|
|
|
* i.e. pressing the mute button or it was programatically triggerred
|
2016-04-01 19:53:11 +00:00
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
onLocalAudioMuted(muted, userInteraction) {
|
|
|
|
if (!this.player) {
|
2016-04-01 19:53:11 +00:00
|
|
|
return;
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
2016-04-01 19:53:11 +00:00
|
|
|
|
2016-04-19 18:07:04 +00:00
|
|
|
if (muted) {
|
|
|
|
this.mutedWithUserInteraction = userInteraction;
|
2017-10-12 23:02:29 +00:00
|
|
|
} else if (this.player.getPlayerState() !== YT.PlayerState.PAUSED) {
|
2016-04-28 16:54:10 +00:00
|
|
|
this.smartPlayerMute(true, false);
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-04-28 16:54:10 +00:00
|
|
|
// Check if we need to update other participants
|
|
|
|
this.fireSharedVideoEvent();
|
2016-04-25 20:39:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Mutes / unmutes the player.
|
|
|
|
* @param mute true to mute the shared video, false - otherwise.
|
2016-04-28 16:54:10 +00:00
|
|
|
* @param {boolean} Indicates if this mute is a consequence of a network
|
|
|
|
* video update or is called locally.
|
2016-04-25 20:39:31 +00:00
|
|
|
*/
|
2016-04-28 16:54:10 +00:00
|
|
|
smartPlayerMute(mute, isVideoUpdate) {
|
2016-04-25 20:39:31 +00:00
|
|
|
if (!this.player.isMuted() && mute) {
|
|
|
|
this.player.mute();
|
2016-04-28 16:54:10 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
if (isVideoUpdate) {
|
2016-04-28 16:54:10 +00:00
|
|
|
this.smartAudioUnmute();
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
|
|
|
} else if (this.player.isMuted() && !mute) {
|
2016-04-25 20:39:31 +00:00
|
|
|
this.player.unMute();
|
2017-10-12 23:02:29 +00:00
|
|
|
if (isVideoUpdate) {
|
2016-04-28 16:54:10 +00:00
|
|
|
this.smartAudioMute();
|
2017-10-12 23:02:29 +00:00
|
|
|
}
|
2016-04-25 20:39:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Smart mike unmute. If the mike is currently muted and it wasn't muted
|
|
|
|
* by the user via the mike button and the volume of the shared video is on
|
|
|
|
* we're unmuting the mike automatically.
|
|
|
|
*/
|
2016-04-28 16:54:10 +00:00
|
|
|
smartAudioUnmute() {
|
2016-04-25 20:39:31 +00:00
|
|
|
if (APP.conference.isLocalAudioMuted()
|
|
|
|
&& !this.mutedWithUserInteraction
|
|
|
|
&& !this.isSharedVideoVolumeOn()) {
|
2018-01-03 21:24:07 +00:00
|
|
|
sendAnalytics(createEvent('audio.unmuted'));
|
2017-10-09 21:40:38 +00:00
|
|
|
logger.log('Shared video: audio unmuted');
|
2016-04-25 20:39:31 +00:00
|
|
|
this.emitter.emit(UIEvents.AUDIO_MUTED, false, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Smart mike mute. If the mike isn't currently muted and the shared video
|
|
|
|
* volume is on we mute the mike.
|
|
|
|
*/
|
2016-04-28 16:54:10 +00:00
|
|
|
smartAudioMute() {
|
2016-04-25 20:39:31 +00:00
|
|
|
if (!APP.conference.isLocalAudioMuted()
|
|
|
|
&& this.isSharedVideoVolumeOn()) {
|
2018-01-03 21:24:07 +00:00
|
|
|
sendAnalytics(createEvent('audio.muted'));
|
2017-10-09 21:40:38 +00:00
|
|
|
logger.log('Shared video: audio muted');
|
2016-04-25 20:39:31 +00:00
|
|
|
this.emitter.emit(UIEvents.AUDIO_MUTED, true, false);
|
2016-04-01 19:53:11 +00:00
|
|
|
}
|
|
|
|
}
|
2016-03-18 20:00:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Container for shared video iframe.
|
|
|
|
*/
|
|
|
|
class SharedVideoContainer extends LargeContainer {
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
constructor({ url, iframe, player }) {
|
2016-03-18 20:00:55 +00:00
|
|
|
super();
|
|
|
|
|
|
|
|
this.$iframe = $(iframe);
|
|
|
|
this.url = url;
|
|
|
|
this.player = player;
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
show() {
|
|
|
|
const self = this;
|
|
|
|
|
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
return new Promise(resolve => {
|
|
|
|
this.$iframe.fadeIn(300, () => {
|
2016-03-24 19:49:26 +00:00
|
|
|
self.bodyBackground = document.body.style.background;
|
|
|
|
document.body.style.background = 'black';
|
2017-10-12 23:02:29 +00:00
|
|
|
this.$iframe.css({ opacity: 1 });
|
2017-04-01 05:52:40 +00:00
|
|
|
APP.store.dispatch(dockToolbox(true));
|
2016-03-18 20:00:55 +00:00
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
hide() {
|
|
|
|
const self = this;
|
|
|
|
|
2017-04-01 05:52:40 +00:00
|
|
|
APP.store.dispatch(dockToolbox(false));
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
return new Promise(resolve => {
|
|
|
|
this.$iframe.fadeOut(300, () => {
|
2016-03-24 19:49:26 +00:00
|
|
|
document.body.style.background = self.bodyBackground;
|
2017-10-12 23:02:29 +00:00
|
|
|
this.$iframe.css({ opacity: 0 });
|
2016-03-18 20:00:55 +00:00
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
onHoverIn() {
|
2017-04-01 05:52:40 +00:00
|
|
|
APP.store.dispatch(showToolbox());
|
2016-03-18 20:00:55 +00:00
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
get id() {
|
2016-03-18 20:00:55 +00:00
|
|
|
return this.url;
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
resize(containerWidth, containerHeight) {
|
2017-06-14 23:52:59 +00:00
|
|
|
let height, width;
|
2016-03-18 20:00:55 +00:00
|
|
|
|
2017-06-14 23:52:59 +00:00
|
|
|
if (interfaceConfig.VERTICAL_FILMSTRIP) {
|
2018-04-09 05:03:26 +00:00
|
|
|
height = containerHeight - getToolboxHeight();
|
2017-06-14 23:52:59 +00:00
|
|
|
width = containerWidth - Filmstrip.getFilmstripWidth();
|
|
|
|
} else {
|
|
|
|
height = containerHeight - Filmstrip.getFilmstripHeight();
|
|
|
|
width = containerWidth;
|
|
|
|
}
|
2016-03-18 20:00:55 +00:00
|
|
|
|
|
|
|
this.$iframe.width(width).height(height);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {boolean} do not switch on dominant speaker event if on stage.
|
|
|
|
*/
|
2017-10-12 23:02:29 +00:00
|
|
|
stayOnStage() {
|
2016-03-18 20:00:55 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if given string is youtube url.
|
|
|
|
* @param {string} url string to check.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
function getYoutubeLink(url) {
|
2017-10-12 23:02:29 +00:00
|
|
|
const p = /^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/;// eslint-disable-line max-len
|
|
|
|
|
|
|
|
|
|
|
|
return url.match(p) ? RegExp.$1 : false;
|
2016-03-18 20:00:55 +00:00
|
|
|
}
|
|
|
|
|
2016-03-18 22:04:13 +00:00
|
|
|
/**
|
|
|
|
* Ask user if he want to close shared video.
|
|
|
|
*/
|
2016-03-22 19:59:03 +00:00
|
|
|
function showStopVideoPropmpt() {
|
2017-10-12 23:02:29 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const submitFunction = function(e, v) {
|
2016-10-12 00:08:24 +00:00
|
|
|
if (v) {
|
|
|
|
resolve();
|
|
|
|
} else {
|
|
|
|
reject();
|
2016-03-18 22:04:13 +00:00
|
|
|
}
|
2016-10-12 00:08:24 +00:00
|
|
|
};
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const closeFunction = function() {
|
2016-10-12 00:08:24 +00:00
|
|
|
dialog = null;
|
|
|
|
};
|
2016-03-18 22:04:13 +00:00
|
|
|
|
2016-10-12 00:08:24 +00:00
|
|
|
dialog = APP.UI.messageHandler.openTwoButtonDialog({
|
2017-10-12 23:02:29 +00:00
|
|
|
titleKey: 'dialog.removeSharedVideoTitle',
|
|
|
|
msgKey: 'dialog.removeSharedVideoMsg',
|
|
|
|
leftButtonKey: 'dialog.Remove',
|
2016-10-12 00:08:24 +00:00
|
|
|
submitFunction,
|
|
|
|
closeFunction
|
|
|
|
});
|
2016-03-18 22:04:13 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
/**
|
|
|
|
* Ask user for shared video url to share with others.
|
|
|
|
* Dialog validates client input to allow only youtube urls.
|
|
|
|
*/
|
|
|
|
function requestVideoLink() {
|
2017-10-12 23:02:29 +00:00
|
|
|
const i18n = APP.translation;
|
|
|
|
const cancelButton = i18n.generateTranslationHTML('dialog.Cancel');
|
|
|
|
const shareButton = i18n.generateTranslationHTML('dialog.Share');
|
|
|
|
const backButton = i18n.generateTranslationHTML('dialog.Back');
|
2016-03-18 20:00:55 +00:00
|
|
|
const linkError
|
2017-10-12 23:02:29 +00:00
|
|
|
= i18n.generateTranslationHTML('dialog.shareVideoLinkError');
|
2016-03-18 20:00:55 +00:00
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2016-07-06 18:26:27 +00:00
|
|
|
dialog = APP.UI.messageHandler.openDialogWithStates({
|
2016-03-18 20:00:55 +00:00
|
|
|
state0: {
|
2017-10-12 23:02:29 +00:00
|
|
|
titleKey: 'dialog.shareVideoTitle',
|
|
|
|
html: `
|
|
|
|
<input name='sharedVideoUrl' type='text'
|
|
|
|
class='input-control'
|
|
|
|
data-i18n='[placeholder]defaultLink'
|
2016-03-18 20:00:55 +00:00
|
|
|
autofocus>`,
|
|
|
|
persistent: false,
|
|
|
|
buttons: [
|
2017-10-12 23:02:29 +00:00
|
|
|
{ title: cancelButton,
|
|
|
|
value: false },
|
|
|
|
{ title: shareButton,
|
|
|
|
value: true }
|
2016-03-18 20:00:55 +00:00
|
|
|
],
|
|
|
|
focus: ':input:first',
|
|
|
|
defaultButton: 1,
|
2017-10-12 23:02:29 +00:00
|
|
|
submit(e, v, m, f) { // eslint-disable-line max-params
|
2016-03-18 20:00:55 +00:00
|
|
|
e.preventDefault();
|
|
|
|
if (!v) {
|
|
|
|
reject('cancelled');
|
|
|
|
dialog.close();
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const sharedVideoUrl = f.sharedVideoUrl;
|
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
if (!sharedVideoUrl) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-12 23:02:29 +00:00
|
|
|
const urlValue
|
|
|
|
= encodeURI(UIUtil.escapeHtml(sharedVideoUrl));
|
|
|
|
const yVideoId = getYoutubeLink(urlValue);
|
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
if (!yVideoId) {
|
|
|
|
dialog.goToState('state1');
|
2017-10-12 23:02:29 +00:00
|
|
|
|
2016-03-18 20:00:55 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
resolve(yVideoId);
|
|
|
|
dialog.close();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
state1: {
|
2017-10-12 23:02:29 +00:00
|
|
|
titleKey: 'dialog.shareVideoTitle',
|
2016-10-12 00:08:24 +00:00
|
|
|
html: linkError,
|
2016-03-18 20:00:55 +00:00
|
|
|
persistent: false,
|
|
|
|
buttons: [
|
2017-10-12 23:02:29 +00:00
|
|
|
{ title: cancelButton,
|
|
|
|
value: false },
|
|
|
|
{ title: backButton,
|
|
|
|
value: true }
|
2016-03-18 20:00:55 +00:00
|
|
|
],
|
|
|
|
focus: ':input:first',
|
|
|
|
defaultButton: 1,
|
2017-10-12 23:02:29 +00:00
|
|
|
submit(e, v) {
|
2016-03-18 20:00:55 +00:00
|
|
|
e.preventDefault();
|
|
|
|
if (v === 0) {
|
|
|
|
reject();
|
|
|
|
dialog.close();
|
|
|
|
} else {
|
|
|
|
dialog.goToState('state0');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-06 18:26:27 +00:00
|
|
|
}, {
|
2017-10-12 23:02:29 +00:00
|
|
|
close() {
|
2016-07-06 18:26:27 +00:00
|
|
|
dialog = null;
|
|
|
|
}
|
2016-10-21 17:11:22 +00:00
|
|
|
}, {
|
|
|
|
url: defaultSharedVideoLink
|
2016-03-18 20:00:55 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|