2015-12-14 12:26:50 +00:00
|
|
|
/* global $, APP, interfaceConfig */
|
|
|
|
|
|
|
|
import ConnectionIndicator from './ConnectionIndicator';
|
|
|
|
|
|
|
|
import SmallVideo from "./SmallVideo";
|
|
|
|
import UIUtils from "../util/UIUtil";
|
|
|
|
import UIEvents from '../../../service/UI/UIEvents';
|
2016-08-04 20:23:38 +00:00
|
|
|
import JitsiPopover from "../util/JitsiPopover";
|
2015-12-14 12:26:50 +00:00
|
|
|
|
2016-09-16 20:17:00 +00:00
|
|
|
/**
|
|
|
|
* Creates new instance of the <tt>RemoteVideo</tt>.
|
|
|
|
* @param user {JitsiParticipant} the user for whom remote video instance will
|
|
|
|
* be created.
|
|
|
|
* @param {VideoLayout} VideoLayout the video layout instance.
|
|
|
|
* @param {EventEmitter} emitter the event emitter which will be used by
|
|
|
|
* the new instance to emit events.
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
function RemoteVideo(user, VideoLayout, emitter) {
|
|
|
|
this.user = user;
|
|
|
|
this.id = user.getId();
|
2015-12-14 12:26:50 +00:00
|
|
|
this.emitter = emitter;
|
2016-09-16 20:17:00 +00:00
|
|
|
this.videoSpanId = `participant_${this.id}`;
|
2016-03-15 20:42:53 +00:00
|
|
|
SmallVideo.call(this, VideoLayout);
|
2016-08-23 23:37:41 +00:00
|
|
|
this.hasRemoteVideoMenu = false;
|
2015-06-23 08:00:46 +00:00
|
|
|
this.addRemoteVideoContainer();
|
2016-09-16 20:17:00 +00:00
|
|
|
this.connectionIndicator = new ConnectionIndicator(this, this.id);
|
2015-06-23 08:00:46 +00:00
|
|
|
this.setDisplayName();
|
|
|
|
this.flipX = false;
|
2015-07-15 10:14:34 +00:00
|
|
|
this.isLocal = false;
|
2016-09-22 20:57:43 +00:00
|
|
|
/**
|
|
|
|
* The flag is set to <tt>true</tt> after the 'onplay' event has been
|
|
|
|
* triggered on the current video element. It goes back to <tt>false</tt>
|
|
|
|
* when the stream is removed. It is used to determine whether the video
|
|
|
|
* playback has ever started.
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
this.wasVideoPlayed = false;
|
2016-09-22 21:21:01 +00:00
|
|
|
/**
|
|
|
|
* The flag is set to <tt>true</tt> if remote participant's video gets muted
|
|
|
|
* during his media connection disruption. This is to prevent black video
|
|
|
|
* being render on the thumbnail, because even though once the video has
|
|
|
|
* been played the image usually remains on the video element it seems that
|
|
|
|
* after longer period of the video element being hidden this image can be
|
|
|
|
* lost.
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
this.mutedWhileDisconnected = false;
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RemoteVideo.prototype = Object.create(SmallVideo.prototype);
|
|
|
|
RemoteVideo.prototype.constructor = RemoteVideo;
|
|
|
|
|
|
|
|
RemoteVideo.prototype.addRemoteVideoContainer = function() {
|
|
|
|
this.container = RemoteVideo.createContainer(this.videoSpanId);
|
2016-08-08 22:03:00 +00:00
|
|
|
|
|
|
|
this.initBrowserSpecificProperties();
|
|
|
|
|
2015-12-14 12:26:50 +00:00
|
|
|
if (APP.conference.isModerator) {
|
2015-06-23 08:00:46 +00:00
|
|
|
this.addRemoteVideoMenu();
|
2015-12-14 12:26:50 +00:00
|
|
|
}
|
2016-09-15 02:20:54 +00:00
|
|
|
|
2016-10-03 16:12:04 +00:00
|
|
|
this.VideoLayout.resizeThumbnails(false, true);
|
2016-09-28 21:31:40 +00:00
|
|
|
|
|
|
|
this.addAudioLevelIndicator();
|
2015-06-23 08:00:46 +00:00
|
|
|
|
|
|
|
return this.container;
|
|
|
|
};
|
|
|
|
|
2016-08-04 20:23:38 +00:00
|
|
|
/**
|
|
|
|
* Initializes the remote participant popup menu, by specifying previously
|
|
|
|
* constructed popupMenuElement, containing all the menu items.
|
|
|
|
*
|
|
|
|
* @param popupMenuElement a pre-constructed element, containing the menu items
|
|
|
|
* to display in the popup
|
|
|
|
*/
|
|
|
|
RemoteVideo.prototype._initPopupMenu = function (popupMenuElement) {
|
|
|
|
this.popover = new JitsiPopover(
|
2016-09-18 21:35:35 +00:00
|
|
|
$("#" + this.videoSpanId + " .remotevideomenu"),
|
2016-08-04 20:23:38 +00:00
|
|
|
{ content: popupMenuElement.outerHTML,
|
|
|
|
skin: "black"});
|
|
|
|
|
|
|
|
// override popover show method to make sure we will update the content
|
|
|
|
// before showing the popover
|
|
|
|
var origShowFunc = this.popover.show;
|
|
|
|
this.popover.show = function () {
|
|
|
|
// update content by forcing it, to finish even if popover
|
|
|
|
// is not visible
|
2016-09-21 18:10:11 +00:00
|
|
|
this.updateRemoteVideoMenu(this.isAudioMuted, true);
|
2016-08-04 20:23:38 +00:00
|
|
|
// call the original show, passing its actual this
|
|
|
|
origShowFunc.call(this.popover);
|
|
|
|
}.bind(this);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates the popup menu content.
|
|
|
|
*
|
|
|
|
* @returns {Element|*} the constructed element, containing popup menu items
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
RemoteVideo.prototype._generatePopupContent = function () {
|
|
|
|
var popupmenuElement = document.createElement('ul');
|
|
|
|
popupmenuElement.className = 'popupmenu';
|
|
|
|
popupmenuElement.id = `remote_popupmenu_${this.id}`;
|
|
|
|
|
|
|
|
var muteMenuItem = document.createElement('li');
|
|
|
|
var muteLinkItem = document.createElement('a');
|
|
|
|
|
|
|
|
var mutedIndicator = "<i class='icon-mic-disabled'></i>";
|
|
|
|
|
|
|
|
var doMuteHTML = mutedIndicator +
|
|
|
|
" <div " +
|
|
|
|
"data-i18n='videothumbnail.domute'>" +
|
|
|
|
APP.translation.translateString("videothumbnail.domute") +
|
|
|
|
"</div>";
|
|
|
|
|
|
|
|
var mutedHTML = mutedIndicator +
|
|
|
|
" <div " +
|
|
|
|
"data-i18n='videothumbnail.muted'>" +
|
|
|
|
APP.translation.translateString("videothumbnail.muted") +
|
|
|
|
"</div>";
|
|
|
|
|
2016-08-23 23:37:41 +00:00
|
|
|
muteLinkItem.id = "mutelink_" + this.id;
|
2016-08-04 20:23:38 +00:00
|
|
|
|
2016-09-21 18:10:11 +00:00
|
|
|
if (this.isAudioMuted) {
|
2016-08-04 20:23:38 +00:00
|
|
|
muteLinkItem.innerHTML = mutedHTML;
|
|
|
|
muteLinkItem.className = 'mutelink disabled';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
muteLinkItem.innerHTML = doMuteHTML;
|
|
|
|
muteLinkItem.className = 'mutelink';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delegate event to the document.
|
2016-08-23 23:37:41 +00:00
|
|
|
$(document).on("click", "#mutelink_" + this.id, function(){
|
2016-08-04 20:23:38 +00:00
|
|
|
|
2016-09-21 18:10:11 +00:00
|
|
|
if (this.isAudioMuted)
|
2016-08-04 20:23:38 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
this.emitter.emit(UIEvents.REMOTE_AUDIO_MUTED, this.id);
|
|
|
|
|
|
|
|
this.popover.forceHide();
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
muteMenuItem.appendChild(muteLinkItem);
|
|
|
|
popupmenuElement.appendChild(muteMenuItem);
|
|
|
|
|
2016-09-12 04:36:15 +00:00
|
|
|
var ejectIndicator = "<i style='float:left;' class='icon-kick'></i>";
|
2016-08-04 20:23:38 +00:00
|
|
|
|
|
|
|
var ejectMenuItem = document.createElement('li');
|
|
|
|
var ejectLinkItem = document.createElement('a');
|
|
|
|
|
|
|
|
var ejectText = "<div " +
|
|
|
|
"data-i18n='videothumbnail.kick'>" +
|
|
|
|
APP.translation.translateString("videothumbnail.kick") +
|
|
|
|
"</div>";
|
|
|
|
|
2016-09-07 15:48:13 +00:00
|
|
|
ejectLinkItem.className = 'ejectlink';
|
2016-08-04 20:23:38 +00:00
|
|
|
ejectLinkItem.innerHTML = ejectIndicator + ' ' + ejectText;
|
2016-08-23 23:37:41 +00:00
|
|
|
ejectLinkItem.id = "ejectlink_" + this.id;
|
2016-08-04 20:23:38 +00:00
|
|
|
|
2016-08-23 23:37:41 +00:00
|
|
|
$(document).on("click", "#ejectlink_" + this.id, function(){
|
2016-08-04 20:23:38 +00:00
|
|
|
this.emitter.emit(UIEvents.USER_KICKED, this.id);
|
|
|
|
this.popover.forceHide();
|
|
|
|
}.bind(this));
|
|
|
|
|
|
|
|
ejectMenuItem.appendChild(ejectLinkItem);
|
|
|
|
popupmenuElement.appendChild(ejectMenuItem);
|
|
|
|
|
|
|
|
return popupmenuElement;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the remote video menu.
|
|
|
|
*
|
|
|
|
* @param isMuted the new muted state to update to
|
|
|
|
* @param force to work even if popover is not visible
|
|
|
|
*/
|
|
|
|
RemoteVideo.prototype.updateRemoteVideoMenu = function (isMuted, force) {
|
|
|
|
|
2016-09-21 18:10:11 +00:00
|
|
|
this.isAudioMuted = isMuted;
|
2016-08-04 20:23:38 +00:00
|
|
|
|
|
|
|
// generate content, translate it and add it to document only if
|
|
|
|
// popover is visible or we force to do so.
|
|
|
|
if(this.popover.popoverShown || force) {
|
|
|
|
this.popover.updateContent(this._generatePopupContent());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-09-22 21:21:01 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
RemoteVideo.prototype.setMutedView = function(isMuted) {
|
|
|
|
SmallVideo.prototype.setMutedView.call(this, isMuted);
|
|
|
|
// Update 'mutedWhileDisconnected' flag
|
|
|
|
this._figureOutMutedWhileDisconnected(this.isConnectionActive() === false);
|
2016-09-28 16:29:47 +00:00
|
|
|
};
|
2016-09-22 21:21:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Figures out the value of {@link #mutedWhileDisconnected} flag by taking into
|
|
|
|
* account remote participant's network connectivity and video muted status.
|
|
|
|
*
|
|
|
|
* @param {boolean} isDisconnected <tt>true</tt> if the remote participant is
|
|
|
|
* currently having connectivity issues or <tt>false</tt> otherwise.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
RemoteVideo.prototype._figureOutMutedWhileDisconnected
|
|
|
|
= function(isDisconnected) {
|
|
|
|
if (isDisconnected && this.isVideoMuted) {
|
|
|
|
this.mutedWhileDisconnected = true;
|
|
|
|
} else if (!isDisconnected && !this.isVideoMuted) {
|
|
|
|
this.mutedWhileDisconnected = false;
|
|
|
|
}
|
2016-09-28 16:29:47 +00:00
|
|
|
};
|
2016-09-22 21:21:01 +00:00
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
/**
|
2015-12-14 12:26:50 +00:00
|
|
|
* Adds the remote video menu element for the given <tt>id</tt> in the
|
2015-06-23 08:00:46 +00:00
|
|
|
* given <tt>parentElement</tt>.
|
|
|
|
*
|
2015-12-14 12:26:50 +00:00
|
|
|
* @param id the id indicating the video for which we're adding a menu.
|
2015-06-23 08:00:46 +00:00
|
|
|
* @param parentElement the parent element where this menu will be added
|
|
|
|
*/
|
2015-08-10 17:59:12 +00:00
|
|
|
if (!interfaceConfig.filmStripOnly) {
|
2015-08-06 23:34:40 +00:00
|
|
|
RemoteVideo.prototype.addRemoteVideoMenu = function () {
|
2016-09-18 21:35:35 +00:00
|
|
|
|
|
|
|
var spanElement = document.createElement('span');
|
|
|
|
spanElement.className = 'remotevideomenu toolbar-icon right';
|
|
|
|
|
|
|
|
this.container
|
|
|
|
.querySelector('.videocontainer__toolbar')
|
|
|
|
.appendChild(spanElement);
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2015-08-06 23:34:40 +00:00
|
|
|
var menuElement = document.createElement('i');
|
2016-09-18 21:35:35 +00:00
|
|
|
menuElement.className = 'icon-menu-up';
|
2015-08-06 23:34:40 +00:00
|
|
|
menuElement.title = 'Remote user controls';
|
|
|
|
spanElement.appendChild(menuElement);
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-08-04 20:23:38 +00:00
|
|
|
this._initPopupMenu(this._generatePopupContent());
|
2016-08-23 23:37:41 +00:00
|
|
|
this.hasRemoteVideoMenu = true;
|
2015-08-06 23:34:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} else {
|
2015-09-11 03:05:53 +00:00
|
|
|
RemoteVideo.prototype.addRemoteVideoMenu = function() {};
|
2015-08-06 23:34:40 +00:00
|
|
|
}
|
2015-06-23 08:00:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the remote stream element corresponding to the given stream and
|
|
|
|
* parent container.
|
|
|
|
*
|
2016-01-29 00:33:27 +00:00
|
|
|
* @param stream the MediaStream
|
2015-06-23 08:00:46 +00:00
|
|
|
* @param isVideo <tt>true</tt> if given <tt>stream</tt> is a video one.
|
|
|
|
*/
|
2016-02-23 22:47:55 +00:00
|
|
|
RemoteVideo.prototype.removeRemoteStreamElement = function (stream) {
|
2015-06-23 08:00:46 +00:00
|
|
|
if (!this.container)
|
|
|
|
return false;
|
|
|
|
|
2016-02-23 22:47:55 +00:00
|
|
|
var isVideo = stream.isVideoTrack();
|
|
|
|
|
|
|
|
var elementID = SmallVideo.getStreamElementID(stream);
|
2016-07-15 18:12:14 +00:00
|
|
|
var select = $('#' + elementID);
|
2015-06-23 08:00:46 +00:00
|
|
|
select.remove();
|
|
|
|
|
2016-09-22 20:57:43 +00:00
|
|
|
if (isVideo) {
|
|
|
|
this.wasVideoPlayed = false;
|
|
|
|
}
|
|
|
|
|
2015-07-30 08:23:21 +00:00
|
|
|
console.info((isVideo ? "Video" : "Audio") +
|
2015-12-14 12:26:50 +00:00
|
|
|
" removed " + this.id, select);
|
2015-07-30 08:23:21 +00:00
|
|
|
|
2016-03-23 22:45:27 +00:00
|
|
|
// when removing only the video element and we are on stage
|
|
|
|
// update the stage
|
2016-09-19 19:04:55 +00:00
|
|
|
if (isVideo && this.isCurrentlyOnLargeVideo())
|
2016-03-23 22:45:27 +00:00
|
|
|
this.VideoLayout.updateLargeVideo(this.id);
|
2016-09-22 21:21:01 +00:00
|
|
|
else
|
|
|
|
// Missing video stream will affect display mode
|
|
|
|
this.updateView();
|
2015-06-23 08:00:46 +00:00
|
|
|
};
|
|
|
|
|
2016-09-16 20:51:19 +00:00
|
|
|
/**
|
|
|
|
* Checks whether the remote user associated with this <tt>RemoteVideo</tt>
|
|
|
|
* has connectivity issues.
|
|
|
|
*
|
|
|
|
* @return {boolean} <tt>true</tt> if the user's connection is fine or
|
|
|
|
* <tt>false</tt> otherwise.
|
|
|
|
*/
|
|
|
|
RemoteVideo.prototype.isConnectionActive = function() {
|
|
|
|
return this.user.isConnectionActive();
|
|
|
|
};
|
|
|
|
|
2016-09-19 20:59:56 +00:00
|
|
|
/**
|
|
|
|
* The remote video is considered "playable" once the stream has started
|
|
|
|
* according to the {@link #hasVideoStarted} result.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
RemoteVideo.prototype.isVideoPlayable = function () {
|
|
|
|
return SmallVideo.prototype.isVideoPlayable.call(this)
|
2016-09-22 21:21:01 +00:00
|
|
|
&& this.hasVideoStarted() && !this.mutedWhileDisconnected;
|
2016-09-19 20:59:56 +00:00
|
|
|
};
|
|
|
|
|
2016-09-16 20:51:19 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
RemoteVideo.prototype.updateView = function () {
|
2016-09-22 21:21:01 +00:00
|
|
|
|
2016-09-16 20:51:19 +00:00
|
|
|
this.updateConnectionStatusIndicator(
|
|
|
|
null /* will obtain the status from 'conference' */);
|
2016-09-22 21:21:01 +00:00
|
|
|
|
|
|
|
// This must be called after 'updateConnectionStatusIndicator' because it
|
|
|
|
// affects the display mode by modifying 'mutedWhileDisconnected' flag
|
|
|
|
SmallVideo.prototype.updateView.call(this);
|
2016-09-16 20:51:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the UI to reflect user's connectivity status.
|
|
|
|
* @param isActive {boolean|null} 'true' if user's connection is active or
|
|
|
|
* 'false' when the use is having some connectivity issues and a warning
|
|
|
|
* should be displayed. When 'null' is passed then the current value will be
|
|
|
|
* obtained from the conference instance.
|
|
|
|
*/
|
|
|
|
RemoteVideo.prototype.updateConnectionStatusIndicator = function (isActive) {
|
|
|
|
// Check for initial value if 'isActive' is not defined
|
|
|
|
if (typeof isActive !== "boolean") {
|
|
|
|
isActive = this.isConnectionActive();
|
|
|
|
if (isActive === null) {
|
|
|
|
// Cancel processing at this point - no update
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
console.debug(this.id + " thumbnail is connection active ? " + isActive);
|
|
|
|
|
2016-09-22 21:21:01 +00:00
|
|
|
// Update 'mutedWhileDisconnected' flag
|
|
|
|
this._figureOutMutedWhileDisconnected(!isActive);
|
|
|
|
|
2016-09-16 20:51:19 +00:00
|
|
|
if(this.connectionIndicator)
|
|
|
|
this.connectionIndicator.updateConnectionStatusIndicator(isActive);
|
2016-09-19 19:18:52 +00:00
|
|
|
|
|
|
|
// Toggle thumbnail video problem filter
|
|
|
|
this.selectVideoElement().toggleClass(
|
|
|
|
"videoThumbnailProblemFilter", !isActive);
|
|
|
|
this.$avatar().toggleClass(
|
|
|
|
"videoThumbnailProblemFilter", !isActive);
|
2015-06-23 08:00:46 +00:00
|
|
|
};
|
|
|
|
|
2015-07-29 16:41:22 +00:00
|
|
|
/**
|
|
|
|
* Removes RemoteVideo from the page.
|
|
|
|
*/
|
|
|
|
RemoteVideo.prototype.remove = function () {
|
2015-12-14 12:26:50 +00:00
|
|
|
console.log("Remove thumbnail", this.id);
|
2015-07-29 16:41:22 +00:00
|
|
|
this.removeConnectionIndicator();
|
2015-10-01 22:46:42 +00:00
|
|
|
// Make sure that the large video is updated if are removing its
|
|
|
|
// corresponding small video.
|
2016-03-23 22:45:27 +00:00
|
|
|
this.VideoLayout.updateAfterThumbRemoved(this.id);
|
2015-07-29 16:41:22 +00:00
|
|
|
// Remove whole container
|
2015-12-14 12:26:50 +00:00
|
|
|
if (this.container.parentNode) {
|
2015-07-29 16:41:22 +00:00
|
|
|
this.container.parentNode.removeChild(this.container);
|
2015-12-14 12:26:50 +00:00
|
|
|
}
|
2015-07-29 16:41:22 +00:00
|
|
|
};
|
|
|
|
|
2016-02-01 21:00:51 +00:00
|
|
|
RemoteVideo.prototype.waitForPlayback = function (streamElement, stream) {
|
2015-07-15 12:01:36 +00:00
|
|
|
|
2015-11-06 21:59:38 +00:00
|
|
|
var webRtcStream = stream.getOriginalStream();
|
2015-12-14 12:26:50 +00:00
|
|
|
var isVideo = stream.isVideoTrack();
|
2015-11-06 21:59:38 +00:00
|
|
|
if (!isVideo || webRtcStream.id === 'mixedmslabel') {
|
2015-07-15 12:01:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
// Register 'onplaying' listener to trigger 'videoactive' on VideoLayout
|
|
|
|
// when video playback starts
|
|
|
|
var onPlayingHandler = function () {
|
2016-09-22 20:57:43 +00:00
|
|
|
self.wasVideoPlayed = true;
|
2016-02-01 21:00:51 +00:00
|
|
|
self.VideoLayout.videoactive(streamElement, self.id);
|
|
|
|
streamElement.onplaying = null;
|
2016-09-19 19:18:52 +00:00
|
|
|
// Refresh to show the video
|
|
|
|
self.updateView();
|
2015-07-15 12:01:36 +00:00
|
|
|
};
|
2016-02-01 21:00:51 +00:00
|
|
|
streamElement.onplaying = onPlayingHandler;
|
2015-07-15 12:01:36 +00:00
|
|
|
};
|
|
|
|
|
2016-02-01 22:08:15 +00:00
|
|
|
/**
|
2016-09-22 20:57:43 +00:00
|
|
|
* Checks whether the video stream has started for this RemoteVideo instance.
|
2016-02-01 22:08:15 +00:00
|
|
|
*
|
2016-09-22 20:57:43 +00:00
|
|
|
* @returns {boolean} true if this RemoteVideo has a video stream for which
|
|
|
|
* the playback has been started.
|
2016-02-01 22:08:15 +00:00
|
|
|
*/
|
|
|
|
RemoteVideo.prototype.hasVideoStarted = function () {
|
2016-09-22 20:57:43 +00:00
|
|
|
return this.wasVideoPlayed;
|
2016-02-01 22:08:15 +00:00
|
|
|
};
|
|
|
|
|
2015-10-01 20:10:55 +00:00
|
|
|
RemoteVideo.prototype.addRemoteStreamElement = function (stream) {
|
2015-12-14 12:26:50 +00:00
|
|
|
if (!this.container) {
|
2015-06-23 08:00:46 +00:00
|
|
|
return;
|
2015-12-14 12:26:50 +00:00
|
|
|
}
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2015-12-14 12:26:50 +00:00
|
|
|
let isVideo = stream.isVideoTrack();
|
2016-01-29 00:33:27 +00:00
|
|
|
isVideo ? this.videoStream = stream : this.audioStream = stream;
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-07-21 03:13:26 +00:00
|
|
|
if (isVideo)
|
|
|
|
this.setVideoType(stream.videoType);
|
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
// Add click handler.
|
2015-12-14 12:26:50 +00:00
|
|
|
let onClickHandler = (event) => {
|
2016-01-28 14:36:55 +00:00
|
|
|
let source = event.target || event.srcElement;
|
2015-07-20 17:32:04 +00:00
|
|
|
|
2016-01-28 14:36:55 +00:00
|
|
|
// ignore click if it was done in popup menu
|
|
|
|
if ($(source).parents('.popupmenu').length === 0) {
|
2016-03-24 01:43:29 +00:00
|
|
|
this.VideoLayout.handleVideoThumbClicked(this.id);
|
2016-01-28 14:36:55 +00:00
|
|
|
}
|
2015-07-20 17:32:04 +00:00
|
|
|
|
2015-07-10 09:57:20 +00:00
|
|
|
// On IE we need to populate this handler on video <object>
|
|
|
|
// and it does not give event instance as an argument,
|
|
|
|
// so we check here for methods.
|
|
|
|
if (event.stopPropagation && event.preventDefault) {
|
|
|
|
event.stopPropagation();
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
2015-06-23 08:00:46 +00:00
|
|
|
return false;
|
|
|
|
};
|
2015-07-10 09:57:20 +00:00
|
|
|
this.container.onclick = onClickHandler;
|
2016-01-22 22:37:33 +00:00
|
|
|
|
|
|
|
if(!stream.getOriginalStream())
|
|
|
|
return;
|
|
|
|
|
|
|
|
let streamElement = SmallVideo.createStreamElement(stream);
|
|
|
|
|
|
|
|
// Put new stream element always in front
|
|
|
|
UIUtils.prependChild(this.container, streamElement);
|
|
|
|
|
2016-02-01 21:00:51 +00:00
|
|
|
// If we hide element when Temasys plugin is used then
|
|
|
|
// we'll never receive 'onplay' event and other logic won't work as expected
|
2016-02-02 21:50:02 +00:00
|
|
|
// NOTE: hiding will not have effect when Temasys plugin is in use, as
|
|
|
|
// calling attach will show it back
|
|
|
|
$(streamElement).hide();
|
2016-01-22 22:37:33 +00:00
|
|
|
|
2016-02-10 15:26:16 +00:00
|
|
|
// If the container is currently visible
|
|
|
|
// we attach the stream to the element.
|
2016-01-22 22:37:33 +00:00
|
|
|
if (!isVideo || (this.container.offsetParent !== null && isVideo)) {
|
2016-02-01 21:00:51 +00:00
|
|
|
this.waitForPlayback(streamElement, stream);
|
2016-01-22 22:37:33 +00:00
|
|
|
|
2016-02-01 21:00:51 +00:00
|
|
|
streamElement = stream.attach(streamElement);
|
2016-01-22 22:37:33 +00:00
|
|
|
}
|
|
|
|
|
2016-02-01 21:00:51 +00:00
|
|
|
$(streamElement).click(onClickHandler);
|
2015-07-10 09:57:20 +00:00
|
|
|
},
|
2015-06-23 08:00:46 +00:00
|
|
|
|
|
|
|
/**
|
2015-12-14 12:26:50 +00:00
|
|
|
* Show/hide peer container for the given id.
|
2015-06-23 08:00:46 +00:00
|
|
|
*/
|
|
|
|
RemoteVideo.prototype.showPeerContainer = function (state) {
|
|
|
|
if (!this.container)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var isHide = state === 'hide';
|
|
|
|
var resizeThumbnails = false;
|
|
|
|
|
|
|
|
if (!isHide) {
|
|
|
|
if (!$(this.container).is(':visible')) {
|
|
|
|
resizeThumbnails = true;
|
|
|
|
$(this.container).show();
|
|
|
|
}
|
2016-01-14 16:28:24 +00:00
|
|
|
// Call updateView, so that we'll figure out if avatar
|
2015-09-17 16:31:26 +00:00
|
|
|
// should be displayed based on video muted status and whether or not
|
|
|
|
// it's in the lastN set
|
2016-01-14 16:28:24 +00:00
|
|
|
this.updateView();
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
|
|
|
else if ($(this.container).is(':visible') && isHide)
|
|
|
|
{
|
|
|
|
resizeThumbnails = true;
|
|
|
|
$(this.container).hide();
|
|
|
|
if(this.connectionIndicator)
|
|
|
|
this.connectionIndicator.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (resizeThumbnails) {
|
|
|
|
this.VideoLayout.resizeThumbnails();
|
|
|
|
}
|
|
|
|
|
|
|
|
// We want to be able to pin a participant from the contact list, even
|
|
|
|
// if he's not in the lastN set!
|
2015-12-14 12:26:50 +00:00
|
|
|
// ContactList.setClickable(id, !isHide);
|
2015-06-23 08:00:46 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-12-29 12:41:43 +00:00
|
|
|
RemoteVideo.prototype.updateResolution = function (resolution) {
|
|
|
|
if (this.connectionIndicator) {
|
|
|
|
this.connectionIndicator.updateResolution(resolution);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
RemoteVideo.prototype.removeConnectionIndicator = function () {
|
2015-07-29 16:41:22 +00:00
|
|
|
if (this.connectionIndicator)
|
2015-06-23 08:00:46 +00:00
|
|
|
this.connectionIndicator.remove();
|
2015-07-29 16:41:22 +00:00
|
|
|
};
|
2015-06-23 08:00:46 +00:00
|
|
|
|
|
|
|
RemoteVideo.prototype.hideConnectionIndicator = function () {
|
2015-07-29 16:41:22 +00:00
|
|
|
if (this.connectionIndicator)
|
2015-06-23 08:00:46 +00:00
|
|
|
this.connectionIndicator.hide();
|
2015-07-29 16:41:22 +00:00
|
|
|
};
|
2015-06-23 08:00:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the display name for the given video span id.
|
|
|
|
*/
|
|
|
|
RemoteVideo.prototype.setDisplayName = function(displayName, key) {
|
|
|
|
|
|
|
|
if (!this.container) {
|
2015-07-28 21:52:32 +00:00
|
|
|
console.warn( "Unable to set displayName - " + this.videoSpanId +
|
|
|
|
" does not exist");
|
2015-06-23 08:00:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-18 21:35:35 +00:00
|
|
|
var nameSpan = $('#' + this.videoSpanId + ' .displayname');
|
2015-06-23 08:00:46 +00:00
|
|
|
|
|
|
|
// If we already have a display name for this video.
|
|
|
|
if (nameSpan.length > 0) {
|
2015-07-28 21:52:32 +00:00
|
|
|
if (displayName && displayName.length > 0) {
|
2016-04-09 17:04:01 +00:00
|
|
|
var displaynameSpan = $('#' + this.videoSpanId + '_name');
|
|
|
|
if (displaynameSpan.text() !== displayName)
|
|
|
|
displaynameSpan.text(displayName);
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
2015-07-28 21:52:32 +00:00
|
|
|
else if (key && key.length > 0) {
|
2015-07-03 09:34:05 +00:00
|
|
|
var nameHtml = APP.translation.generateTranslationHTML(key);
|
2015-06-23 08:00:46 +00:00
|
|
|
$('#' + this.videoSpanId + '_name').html(nameHtml);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
$('#' + this.videoSpanId + '_name').text(
|
|
|
|
interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME);
|
|
|
|
} else {
|
|
|
|
nameSpan = document.createElement('span');
|
|
|
|
nameSpan.className = 'displayname';
|
2016-09-18 21:35:35 +00:00
|
|
|
$('#' + this.videoSpanId)[0]
|
|
|
|
.querySelector('.videocontainer__toolbar')
|
|
|
|
.appendChild(nameSpan);
|
2015-06-23 08:00:46 +00:00
|
|
|
|
|
|
|
if (displayName && displayName.length > 0) {
|
2016-02-12 12:48:57 +00:00
|
|
|
$(nameSpan).text(displayName);
|
|
|
|
} else {
|
2016-01-14 22:34:22 +00:00
|
|
|
nameSpan.innerHTML = interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME;
|
2016-02-12 12:48:57 +00:00
|
|
|
}
|
2015-06-23 08:00:46 +00:00
|
|
|
nameSpan.id = this.videoSpanId + '_name';
|
|
|
|
}
|
2015-07-28 21:52:32 +00:00
|
|
|
};
|
2015-06-23 08:00:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes remote video menu element from video element identified by
|
|
|
|
* given <tt>videoElementId</tt>.
|
|
|
|
*
|
|
|
|
* @param videoElementId the id of local or remote video element.
|
|
|
|
*/
|
|
|
|
RemoteVideo.prototype.removeRemoteVideoMenu = function() {
|
2016-09-18 21:35:35 +00:00
|
|
|
var menuSpan = $('#' + this.videoSpanId + '> .remotevideomenu');
|
2015-06-23 08:00:46 +00:00
|
|
|
if (menuSpan.length) {
|
2016-08-04 20:23:38 +00:00
|
|
|
this.popover.forceHide();
|
2015-06-23 08:00:46 +00:00
|
|
|
menuSpan.remove();
|
2016-08-23 23:37:41 +00:00
|
|
|
this.hasRemoteVideoMenu = false;
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
2015-07-20 17:32:04 +00:00
|
|
|
};
|
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
RemoteVideo.createContainer = function (spanId) {
|
2016-09-15 02:20:54 +00:00
|
|
|
let container = document.createElement('span');
|
2015-06-23 08:00:46 +00:00
|
|
|
container.id = spanId;
|
|
|
|
container.className = 'videocontainer';
|
2016-09-15 02:20:54 +00:00
|
|
|
|
|
|
|
let toolbar = document.createElement('div');
|
|
|
|
toolbar.className = "videocontainer__toolbar";
|
|
|
|
container.appendChild(toolbar);
|
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
var remotes = document.getElementById('remoteVideos');
|
|
|
|
return remotes.appendChild(container);
|
|
|
|
};
|
|
|
|
|
2015-12-14 12:26:50 +00:00
|
|
|
export default RemoteVideo;
|