2017-03-21 17:14:13 +00:00
|
|
|
/* global $, APP, JitsiMeetJS, interfaceConfig */
|
2016-11-11 15:00:54 +00:00
|
|
|
const logger = require("jitsi-meet-logger").getLogger(__filename);
|
|
|
|
|
2015-12-14 12:26:50 +00:00
|
|
|
import Avatar from "../avatar/Avatar";
|
|
|
|
import UIUtil from "../util/UIUtil";
|
2016-07-08 20:14:49 +00:00
|
|
|
import UIEvents from "../../../service/UI/UIEvents";
|
2016-09-28 21:31:40 +00:00
|
|
|
import AudioLevels from "../audio_levels/AudioLevels";
|
2015-12-14 12:26:50 +00:00
|
|
|
|
2016-02-02 17:37:06 +00:00
|
|
|
const RTCUIHelper = JitsiMeetJS.util.RTCUIHelper;
|
|
|
|
|
2016-09-19 20:59:56 +00:00
|
|
|
/**
|
|
|
|
* Display mode constant used when video is being displayed on the small video.
|
|
|
|
* @type {number}
|
|
|
|
* @constant
|
|
|
|
*/
|
|
|
|
const DISPLAY_VIDEO = 0;
|
|
|
|
/**
|
|
|
|
* Display mode constant used when the user's avatar is being displayed on
|
|
|
|
* the small video.
|
|
|
|
* @type {number}
|
|
|
|
* @constant
|
|
|
|
*/
|
|
|
|
const DISPLAY_AVATAR = 1;
|
|
|
|
/**
|
|
|
|
* Display mode constant used when neither video nor avatar is being displayed
|
2016-10-27 18:17:17 +00:00
|
|
|
* on the small video. And we just show the display name.
|
2016-09-19 20:59:56 +00:00
|
|
|
* @type {number}
|
|
|
|
* @constant
|
|
|
|
*/
|
2016-10-27 18:17:17 +00:00
|
|
|
const DISPLAY_BLACKNESS_WITH_NAME = 2;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display mode constant used when video is displayed and display name
|
|
|
|
* at the same time.
|
|
|
|
* @type {number}
|
|
|
|
* @constant
|
|
|
|
*/
|
|
|
|
const DISPLAY_VIDEO_WITH_NAME = 3;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display mode constant used when neither video nor avatar is being displayed
|
|
|
|
* on the small video. And we just show the display name.
|
|
|
|
* @type {number}
|
|
|
|
* @constant
|
|
|
|
*/
|
|
|
|
const DISPLAY_AVATAR_WITH_NAME = 4;
|
2016-09-19 20:59:56 +00:00
|
|
|
|
2016-03-15 20:42:53 +00:00
|
|
|
function SmallVideo(VideoLayout) {
|
2016-09-21 18:10:11 +00:00
|
|
|
this.isAudioMuted = false;
|
2015-06-29 14:24:21 +00:00
|
|
|
this.hasAvatar = false;
|
2016-01-14 16:28:24 +00:00
|
|
|
this.isVideoMuted = false;
|
2016-01-29 00:33:27 +00:00
|
|
|
this.videoStream = null;
|
|
|
|
this.audioStream = null;
|
2016-03-15 20:42:53 +00:00
|
|
|
this.VideoLayout = VideoLayout;
|
2016-10-27 18:17:17 +00:00
|
|
|
this.videoIsHovered = false;
|
2016-11-04 22:02:30 +00:00
|
|
|
this.hideDisplayName = false;
|
|
|
|
// we can stop updating the thumbnail
|
|
|
|
this.disableUpdateView = false;
|
2015-06-29 14:24:21 +00:00
|
|
|
}
|
|
|
|
|
2016-03-24 01:43:29 +00:00
|
|
|
/**
|
|
|
|
* Returns the identifier of this small video.
|
|
|
|
*
|
|
|
|
* @returns the identifier of this small video
|
|
|
|
*/
|
|
|
|
SmallVideo.prototype.getId = function () {
|
|
|
|
return this.id;
|
|
|
|
};
|
2016-01-29 00:33:27 +00:00
|
|
|
|
|
|
|
/* Indicates if this small video is currently visible.
|
2016-01-26 21:26:28 +00:00
|
|
|
*
|
|
|
|
* @return <tt>true</tt> if this small video isn't currently visible and
|
|
|
|
* <tt>false</tt> - otherwise.
|
|
|
|
*/
|
|
|
|
SmallVideo.prototype.isVisible = function () {
|
|
|
|
return $('#' + this.videoSpanId).is(':visible');
|
|
|
|
};
|
|
|
|
|
2016-04-07 17:08:00 +00:00
|
|
|
/**
|
|
|
|
* Enables / disables the device availability icons for this small video.
|
|
|
|
* @param {enable} set to {true} to enable and {false} to disable
|
|
|
|
*/
|
|
|
|
SmallVideo.prototype.enableDeviceAvailabilityIcons = function (enable) {
|
|
|
|
if (typeof enable === "undefined")
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.deviceAvailabilityIconsEnabled = enable;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the device "non" availability icons.
|
|
|
|
* @param devices the devices, which will be checked for availability
|
|
|
|
*/
|
2015-06-23 08:00:46 +00:00
|
|
|
SmallVideo.prototype.setDeviceAvailabilityIcons = function (devices) {
|
2016-04-07 17:08:00 +00:00
|
|
|
if (!this.deviceAvailabilityIconsEnabled)
|
|
|
|
return;
|
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
if(!this.container)
|
|
|
|
return;
|
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
var noMic = $("#" + this.videoSpanId + " > .noMic");
|
|
|
|
var noVideo = $("#" + this.videoSpanId + " > .noVideo");
|
|
|
|
|
|
|
|
noMic.remove();
|
|
|
|
noVideo.remove();
|
|
|
|
if (!devices.audio) {
|
2015-06-23 08:00:46 +00:00
|
|
|
this.container.appendChild(
|
2015-07-28 21:52:32 +00:00
|
|
|
document.createElement("div")).setAttribute("class", "noMic");
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
if (!devices.video) {
|
2015-06-23 08:00:46 +00:00
|
|
|
this.container.appendChild(
|
2015-07-28 21:52:32 +00:00
|
|
|
document.createElement("div")).setAttribute("class", "noVideo");
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
|
|
|
|
2015-07-28 21:52:32 +00:00
|
|
|
if (!devices.audio && !devices.video) {
|
|
|
|
noMic.css("background-position", "75%");
|
|
|
|
noVideo.css("background-position", "25%");
|
|
|
|
noVideo.css("background-color", "transparent");
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
2015-07-28 21:52:32 +00:00
|
|
|
};
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2015-08-05 12:09:12 +00:00
|
|
|
/**
|
|
|
|
* Sets the type of the video displayed by this instance.
|
2016-11-08 02:38:14 +00:00
|
|
|
* Note that this is a string without clearly defined or checked values, and
|
|
|
|
* it is NOT one of the strings defined in service/RTC/VideoType in
|
|
|
|
* lib-jitsi-meet.
|
|
|
|
* @param videoType 'camera' or 'desktop', or 'sharedvideo'.
|
2015-08-05 12:09:12 +00:00
|
|
|
*/
|
|
|
|
SmallVideo.prototype.setVideoType = function (videoType) {
|
|
|
|
this.videoType = videoType;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the type of the video displayed by this instance.
|
2016-11-08 02:38:14 +00:00
|
|
|
* Note that this is a string without clearly defined or checked values, and
|
|
|
|
* it is NOT one of the strings defined in service/RTC/VideoType in
|
|
|
|
* lib-jitsi-meet.
|
|
|
|
* @returns {String} 'camera', 'screen', 'sharedvideo', or undefined.
|
2015-08-05 12:09:12 +00:00
|
|
|
*/
|
|
|
|
SmallVideo.prototype.getVideoType = function () {
|
|
|
|
return this.videoType;
|
|
|
|
};
|
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
/**
|
2015-10-01 20:10:55 +00:00
|
|
|
* Creates an audio or video element for a particular MediaStream.
|
2015-06-23 08:00:46 +00:00
|
|
|
*/
|
2015-10-01 20:10:55 +00:00
|
|
|
SmallVideo.createStreamElement = function (stream) {
|
2015-12-14 12:26:50 +00:00
|
|
|
let isVideo = stream.isVideoTrack();
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2015-12-14 12:26:50 +00:00
|
|
|
let element = isVideo
|
|
|
|
? document.createElement('video')
|
2015-06-23 08:00:46 +00:00
|
|
|
: document.createElement('audio');
|
2015-10-28 17:04:34 +00:00
|
|
|
if (isVideo) {
|
|
|
|
element.setAttribute("muted", "true");
|
|
|
|
}
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-02-02 21:50:02 +00:00
|
|
|
RTCUIHelper.setAutoPlay(element, true);
|
2015-10-01 20:10:55 +00:00
|
|
|
|
2016-02-23 22:47:55 +00:00
|
|
|
element.id = SmallVideo.getStreamElementID(stream);
|
2015-10-01 20:10:55 +00:00
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
return element;
|
|
|
|
};
|
|
|
|
|
2016-02-23 22:47:55 +00:00
|
|
|
/**
|
|
|
|
* Returns the element id for a particular MediaStream.
|
|
|
|
*/
|
|
|
|
SmallVideo.getStreamElementID = function (stream) {
|
|
|
|
let isVideo = stream.isVideoTrack();
|
|
|
|
|
|
|
|
return (isVideo ? 'remoteVideo_' : 'remoteAudio_') + stream.getId();
|
|
|
|
};
|
|
|
|
|
2016-10-26 20:45:51 +00:00
|
|
|
/**
|
2016-10-27 18:17:17 +00:00
|
|
|
* Configures hoverIn/hoverOut handlers. Depends on connection indicator.
|
2016-10-26 20:45:51 +00:00
|
|
|
*/
|
|
|
|
SmallVideo.prototype.bindHoverHandler = function () {
|
|
|
|
// Add hover handler
|
|
|
|
$(this.container).hover(
|
2016-10-26 22:18:36 +00:00
|
|
|
() => {
|
2016-10-27 18:17:17 +00:00
|
|
|
this.videoIsHovered = true;
|
|
|
|
this.updateView();
|
2016-10-26 20:45:51 +00:00
|
|
|
},
|
2016-10-26 22:18:36 +00:00
|
|
|
() => {
|
2016-10-27 18:17:17 +00:00
|
|
|
this.videoIsHovered = false;
|
|
|
|
this.updateView();
|
2016-10-26 20:45:51 +00:00
|
|
|
}
|
|
|
|
);
|
2016-10-27 18:17:17 +00:00
|
|
|
if (this.connectionIndicator) {
|
|
|
|
this.connectionIndicator.addPopoverHoverListener(
|
|
|
|
() => {
|
|
|
|
this.updateView();
|
|
|
|
});
|
|
|
|
}
|
2016-10-26 20:45:51 +00:00
|
|
|
};
|
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
/**
|
|
|
|
* Updates the data for the indicator
|
|
|
|
* @param id the id of the indicator
|
|
|
|
* @param percent the percent for connection quality
|
|
|
|
* @param object the data
|
|
|
|
*/
|
|
|
|
SmallVideo.prototype.updateStatsIndicator = function (percent, object) {
|
|
|
|
if(this.connectionIndicator)
|
|
|
|
this.connectionIndicator.updateConnectionQuality(percent, object);
|
2015-07-28 21:52:32 +00:00
|
|
|
};
|
2015-06-23 08:00:46 +00:00
|
|
|
|
|
|
|
SmallVideo.prototype.hideIndicator = function () {
|
|
|
|
if(this.connectionIndicator)
|
|
|
|
this.connectionIndicator.hideIndicator();
|
2015-07-28 21:52:32 +00:00
|
|
|
};
|
2015-06-23 08:00:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-09-18 21:35:35 +00:00
|
|
|
* Shows / hides the audio muted indicator over small videos.
|
|
|
|
*
|
2016-09-19 23:04:55 +00:00
|
|
|
* @param {boolean} isMuted indicates if the muted element should be shown
|
2016-09-18 21:35:35 +00:00
|
|
|
* or hidden
|
2015-06-23 08:00:46 +00:00
|
|
|
*/
|
2016-11-23 21:04:05 +00:00
|
|
|
SmallVideo.prototype.showAudioIndicator = function (isMuted) {
|
2016-11-04 14:48:52 +00:00
|
|
|
let mutedIndicator = this.getAudioMutedIndicator();
|
2016-11-23 21:04:05 +00:00
|
|
|
|
2016-11-29 21:07:18 +00:00
|
|
|
UIUtil.setVisible(mutedIndicator, isMuted);
|
2016-11-10 12:45:42 +00:00
|
|
|
|
|
|
|
this.isAudioMuted = isMuted;
|
2015-06-23 08:00:46 +00:00
|
|
|
};
|
|
|
|
|
2016-09-18 21:35:35 +00:00
|
|
|
/**
|
|
|
|
* Returns the audio muted indicator jquery object. If it doesn't exists -
|
|
|
|
* creates it.
|
|
|
|
*
|
2016-11-04 14:48:52 +00:00
|
|
|
* @returns {HTMLElement} the audio muted indicator
|
2016-09-18 21:35:35 +00:00
|
|
|
*/
|
|
|
|
SmallVideo.prototype.getAudioMutedIndicator = function () {
|
2016-11-04 14:48:52 +00:00
|
|
|
let selector = '#' + this.videoSpanId + ' .audioMuted';
|
|
|
|
let audioMutedSpan = document.querySelector(selector);
|
2016-09-18 21:35:35 +00:00
|
|
|
|
2016-10-27 14:13:24 +00:00
|
|
|
if (audioMutedSpan) {
|
2016-09-18 21:35:35 +00:00
|
|
|
return audioMutedSpan;
|
|
|
|
}
|
|
|
|
|
|
|
|
audioMutedSpan = document.createElement('span');
|
|
|
|
audioMutedSpan.className = 'audioMuted toolbar-icon';
|
2016-09-21 18:10:11 +00:00
|
|
|
|
2016-09-18 21:35:35 +00:00
|
|
|
UIUtil.setTooltip(audioMutedSpan,
|
|
|
|
"videothumbnail.mute",
|
|
|
|
"top");
|
|
|
|
|
2016-11-04 14:48:52 +00:00
|
|
|
let mutedIndicator = document.createElement('i');
|
|
|
|
mutedIndicator.className = 'icon-mic-disabled';
|
|
|
|
audioMutedSpan.appendChild(mutedIndicator);
|
|
|
|
|
2016-09-18 21:35:35 +00:00
|
|
|
this.container
|
|
|
|
.querySelector('.videocontainer__toolbar')
|
|
|
|
.appendChild(audioMutedSpan);
|
|
|
|
|
2016-10-27 14:13:24 +00:00
|
|
|
return audioMutedSpan;
|
2016-09-18 21:35:35 +00:00
|
|
|
};
|
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
/**
|
2016-01-14 16:28:24 +00:00
|
|
|
* Shows video muted indicator over small videos and disables/enables avatar
|
|
|
|
* if video muted.
|
2016-09-19 23:04:55 +00:00
|
|
|
*
|
|
|
|
* @param {boolean} isMuted indicates if we should set the view to muted view
|
|
|
|
* or not
|
2015-06-23 08:00:46 +00:00
|
|
|
*/
|
2016-09-28 21:31:40 +00:00
|
|
|
SmallVideo.prototype.setVideoMutedView = function(isMuted) {
|
2016-01-14 16:28:24 +00:00
|
|
|
this.isVideoMuted = isMuted;
|
|
|
|
this.updateView();
|
2016-11-04 14:48:52 +00:00
|
|
|
|
|
|
|
let element = this.getVideoMutedIndicator();
|
2016-11-23 21:04:05 +00:00
|
|
|
|
2016-11-29 21:07:18 +00:00
|
|
|
UIUtil.setVisible(element, isMuted);
|
2015-06-23 08:00:46 +00:00
|
|
|
};
|
|
|
|
|
2016-09-18 21:35:35 +00:00
|
|
|
/**
|
|
|
|
* Returns the video muted indicator jquery object. If it doesn't exists -
|
|
|
|
* creates it.
|
|
|
|
*
|
2016-09-19 23:04:55 +00:00
|
|
|
* @returns {jQuery|HTMLElement} the video muted indicator
|
2016-09-18 21:35:35 +00:00
|
|
|
*/
|
|
|
|
SmallVideo.prototype.getVideoMutedIndicator = function () {
|
2016-10-27 14:13:24 +00:00
|
|
|
var selector = '#' + this.videoSpanId + ' .videoMuted';
|
|
|
|
var videoMutedSpan = document.querySelector(selector);
|
2016-09-18 21:35:35 +00:00
|
|
|
|
2016-10-27 14:13:24 +00:00
|
|
|
if (videoMutedSpan) {
|
2016-09-18 21:35:35 +00:00
|
|
|
return videoMutedSpan;
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
2016-09-18 21:35:35 +00:00
|
|
|
|
|
|
|
videoMutedSpan = document.createElement('span');
|
|
|
|
videoMutedSpan.className = 'videoMuted toolbar-icon';
|
|
|
|
|
|
|
|
this.container
|
|
|
|
.querySelector('.videocontainer__toolbar')
|
|
|
|
.appendChild(videoMutedSpan);
|
|
|
|
|
|
|
|
var mutedIndicator = document.createElement('i');
|
|
|
|
mutedIndicator.className = 'icon-camera-disabled';
|
2016-09-21 18:10:11 +00:00
|
|
|
|
2016-09-18 21:35:35 +00:00
|
|
|
UIUtil.setTooltip(mutedIndicator,
|
|
|
|
"videothumbnail.videomute",
|
|
|
|
"top");
|
2016-09-21 18:10:11 +00:00
|
|
|
|
2016-09-18 21:35:35 +00:00
|
|
|
videoMutedSpan.appendChild(mutedIndicator);
|
|
|
|
|
2016-10-27 14:13:24 +00:00
|
|
|
return videoMutedSpan;
|
2015-07-28 21:52:32 +00:00
|
|
|
};
|
2015-06-23 08:00:46 +00:00
|
|
|
|
|
|
|
/**
|
2016-09-28 21:31:40 +00:00
|
|
|
* Adds the element indicating the moderator(owner) of the conference.
|
2015-06-23 08:00:46 +00:00
|
|
|
*/
|
2016-09-28 21:31:40 +00:00
|
|
|
SmallVideo.prototype.addModeratorIndicator = function () {
|
|
|
|
|
|
|
|
// Don't create moderator indicator if DISABLE_FOCUS_INDICATOR is true
|
2016-09-27 19:32:54 +00:00
|
|
|
if (interfaceConfig.DISABLE_FOCUS_INDICATOR)
|
|
|
|
return false;
|
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
// Show moderator indicator
|
|
|
|
var indicatorSpan = $('#' + this.videoSpanId + ' .focusindicator');
|
|
|
|
|
2016-09-18 21:35:35 +00:00
|
|
|
if (indicatorSpan.length) {
|
|
|
|
return;
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 21:35:35 +00:00
|
|
|
indicatorSpan = document.createElement('span');
|
|
|
|
indicatorSpan.className = 'focusindicator toolbar-icon right';
|
|
|
|
|
|
|
|
this.container
|
|
|
|
.querySelector('.videocontainer__toolbar')
|
|
|
|
.appendChild(indicatorSpan);
|
|
|
|
|
2015-06-23 08:00:46 +00:00
|
|
|
var moderatorIndicator = document.createElement('i');
|
2016-09-12 04:36:15 +00:00
|
|
|
moderatorIndicator.className = 'icon-star';
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-09-18 21:35:35 +00:00
|
|
|
UIUtil.setTooltip(moderatorIndicator,
|
2015-06-23 08:00:46 +00:00
|
|
|
"videothumbnail.moderator",
|
2016-09-16 03:22:56 +00:00
|
|
|
"top-left");
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-09-18 21:35:35 +00:00
|
|
|
indicatorSpan.appendChild(moderatorIndicator);
|
2015-07-28 21:52:32 +00:00
|
|
|
};
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-09-28 21:31:40 +00:00
|
|
|
/**
|
|
|
|
* Adds the element indicating the audio level of the participant.
|
|
|
|
*/
|
|
|
|
SmallVideo.prototype.addAudioLevelIndicator = function () {
|
|
|
|
var audioSpan = $('#' + this.videoSpanId + ' .audioindicator');
|
|
|
|
|
|
|
|
if (audioSpan.length) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.container.appendChild(
|
|
|
|
AudioLevels.createThumbnailAudioLevelIndicator());
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the audio level for this small video.
|
|
|
|
*
|
|
|
|
* @param lvl the new audio level to set
|
|
|
|
*/
|
|
|
|
SmallVideo.prototype.updateAudioLevelIndicator = function (lvl) {
|
|
|
|
AudioLevels.updateThumbnailAudioLevel(this.videoSpanId, lvl);
|
|
|
|
};
|
|
|
|
|
2016-07-08 01:44:04 +00:00
|
|
|
/**
|
|
|
|
* Removes the element indicating the moderator(owner) of the conference.
|
|
|
|
*/
|
2016-09-28 21:31:40 +00:00
|
|
|
SmallVideo.prototype.removeModeratorIndicator = function () {
|
2016-07-08 01:44:04 +00:00
|
|
|
$('#' + this.videoSpanId + ' .focusindicator').remove();
|
|
|
|
};
|
|
|
|
|
2016-07-08 20:17:05 +00:00
|
|
|
/**
|
|
|
|
* This is an especially interesting function. A naive reader might think that
|
|
|
|
* it returns this SmallVideo's "video" element. But it is much more exciting.
|
|
|
|
* It first finds this video's parent element using jquery, then uses a utility
|
|
|
|
* from lib-jitsi-meet to extract the video element from it (with two more
|
|
|
|
* jquery calls), and finally uses jquery again to encapsulate the video element
|
|
|
|
* in an array. This last step allows (some might prefer "forces") users of
|
|
|
|
* this function to access the video element via the 0th element of the returned
|
|
|
|
* array (after checking its length of course!).
|
|
|
|
*/
|
2015-08-21 14:26:39 +00:00
|
|
|
SmallVideo.prototype.selectVideoElement = function () {
|
2016-02-02 17:37:06 +00:00
|
|
|
return $(RTCUIHelper.findVideoElement($('#' + this.videoSpanId)[0]));
|
2015-08-21 14:26:39 +00:00
|
|
|
};
|
|
|
|
|
2016-09-19 18:57:14 +00:00
|
|
|
/**
|
|
|
|
* Selects the HTML image element which displays user's avatar.
|
|
|
|
*
|
|
|
|
* @return {jQuery|HTMLElement} a jQuery selector pointing to the HTML image
|
|
|
|
* element which displays the user's avatar.
|
|
|
|
*/
|
|
|
|
SmallVideo.prototype.$avatar = function () {
|
|
|
|
return $('#' + this.videoSpanId + ' .userAvatar');
|
|
|
|
};
|
|
|
|
|
2016-10-20 19:28:10 +00:00
|
|
|
/**
|
|
|
|
* Returns the display name element, which appears on the video thumbnail.
|
|
|
|
*
|
|
|
|
* @return {jQuery} a jQuery selector pointing to the display name element of
|
|
|
|
* the video thumbnail
|
|
|
|
*/
|
|
|
|
SmallVideo.prototype.$displayName = function () {
|
|
|
|
return $('#' + this.videoSpanId + ' .displayname');
|
|
|
|
};
|
|
|
|
|
2016-03-31 20:12:33 +00:00
|
|
|
/**
|
|
|
|
* Enables / disables the css responsible for focusing/pinning a video
|
|
|
|
* thumbnail.
|
|
|
|
*
|
|
|
|
* @param isFocused indicates if the thumbnail should be focused/pinned or not
|
|
|
|
*/
|
2015-07-28 21:52:32 +00:00
|
|
|
SmallVideo.prototype.focus = function(isFocused) {
|
2016-03-31 20:12:33 +00:00
|
|
|
var focusedCssClass = "videoContainerFocused";
|
|
|
|
var isFocusClassEnabled = $(this.container).hasClass(focusedCssClass);
|
|
|
|
|
|
|
|
if (!isFocused && isFocusClassEnabled) {
|
|
|
|
$(this.container).removeClass(focusedCssClass);
|
|
|
|
}
|
|
|
|
else if (isFocused && !isFocusClassEnabled) {
|
|
|
|
$(this.container).addClass(focusedCssClass);
|
2015-06-23 08:00:46 +00:00
|
|
|
}
|
2015-07-28 21:52:32 +00:00
|
|
|
};
|
2015-06-23 08:00:46 +00:00
|
|
|
|
|
|
|
SmallVideo.prototype.hasVideo = function () {
|
2015-08-21 14:26:39 +00:00
|
|
|
return this.selectVideoElement().length !== 0;
|
2015-07-28 21:52:32 +00:00
|
|
|
};
|
2015-06-23 08:00:46 +00:00
|
|
|
|
2016-09-19 19:04:55 +00:00
|
|
|
/**
|
|
|
|
* Checks whether the user associated with this <tt>SmallVideo</tt> is currently
|
|
|
|
* being displayed on the "large video".
|
|
|
|
*
|
|
|
|
* @return {boolean} <tt>true</tt> if the user is displayed on the large video
|
|
|
|
* or <tt>false</tt> otherwise.
|
|
|
|
*/
|
|
|
|
SmallVideo.prototype.isCurrentlyOnLargeVideo = function () {
|
|
|
|
return this.VideoLayout.isCurrentlyOnLarge(this.id);
|
|
|
|
};
|
|
|
|
|
2016-09-19 20:59:56 +00:00
|
|
|
/**
|
|
|
|
* Checks whether there is a playable video stream available for the user
|
|
|
|
* associated with this <tt>SmallVideo</tt>.
|
|
|
|
*
|
|
|
|
* @return {boolean} <tt>true</tt> if there is a playable video stream available
|
|
|
|
* or <tt>false</tt> otherwise.
|
|
|
|
*/
|
|
|
|
SmallVideo.prototype.isVideoPlayable = function() {
|
|
|
|
return this.videoStream // Is there anything to display ?
|
|
|
|
&& !this.isVideoMuted && !this.videoStream.isMuted() // Muted ?
|
2017-03-21 17:14:13 +00:00
|
|
|
&& (this.isLocal || APP.conference.isInLastN(this.id));
|
2016-09-19 20:59:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines what should be display on the thumbnail.
|
|
|
|
*
|
|
|
|
* @return {number} one of <tt>DISPLAY_VIDEO</tt>,<tt>DISPLAY_AVATAR</tt>
|
2016-10-27 18:17:17 +00:00
|
|
|
* or <tt>DISPLAY_BLACKNESS_WITH_NAME</tt>.
|
2016-09-19 20:59:56 +00:00
|
|
|
*/
|
|
|
|
SmallVideo.prototype.selectDisplayMode = function() {
|
|
|
|
// Display name is always and only displayed when user is on the stage
|
|
|
|
if (this.isCurrentlyOnLargeVideo()) {
|
2016-10-27 18:17:17 +00:00
|
|
|
return DISPLAY_BLACKNESS_WITH_NAME;
|
2016-09-19 20:59:56 +00:00
|
|
|
} else if (this.isVideoPlayable() && this.selectVideoElement().length) {
|
2016-10-27 18:17:17 +00:00
|
|
|
// check hovering and change state to video with name
|
|
|
|
return this._isHovered() ?
|
|
|
|
DISPLAY_VIDEO_WITH_NAME : DISPLAY_VIDEO;
|
2016-09-19 20:59:56 +00:00
|
|
|
} else {
|
2016-10-27 18:17:17 +00:00
|
|
|
// check hovering and change state to avatar with name
|
|
|
|
return this._isHovered() ?
|
|
|
|
DISPLAY_AVATAR_WITH_NAME : DISPLAY_AVATAR;
|
2016-09-19 20:59:56 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-10-27 18:17:17 +00:00
|
|
|
/**
|
|
|
|
* Checks whether current video is considered hovered. Currently it is hovered
|
|
|
|
* if the mouse is over the video, or if the connection
|
|
|
|
* indicator is shown(hovered).
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
SmallVideo.prototype._isHovered = function () {
|
|
|
|
return this.videoIsHovered
|
2016-10-27 19:08:06 +00:00
|
|
|
|| (this.connectionIndicator
|
|
|
|
&& this.connectionIndicator.popover.popoverIsHovered);
|
2016-10-27 18:17:17 +00:00
|
|
|
};
|
|
|
|
|
2015-06-29 14:24:21 +00:00
|
|
|
/**
|
2016-01-14 16:28:24 +00:00
|
|
|
* Hides or shows the user's avatar.
|
2016-01-14 19:30:56 +00:00
|
|
|
* This update assumes that large video had been updated and we will
|
|
|
|
* reflect it on this small video.
|
2016-01-14 16:28:24 +00:00
|
|
|
*
|
2015-06-29 14:24:21 +00:00
|
|
|
* @param show whether we should show the avatar or not
|
|
|
|
* video because there is no dominant speaker and no focused speaker
|
|
|
|
*/
|
2016-01-14 16:28:24 +00:00
|
|
|
SmallVideo.prototype.updateView = function () {
|
2016-11-04 22:02:30 +00:00
|
|
|
if (this.disableUpdateView)
|
|
|
|
return;
|
|
|
|
|
2015-07-20 17:32:04 +00:00
|
|
|
if (!this.hasAvatar) {
|
2015-12-14 12:26:50 +00:00
|
|
|
if (this.id) {
|
2015-07-20 17:32:04 +00:00
|
|
|
// Init avatar
|
2016-01-19 23:10:44 +00:00
|
|
|
this.avatarChanged(Avatar.getAvatarUrl(this.id));
|
2015-07-20 17:32:04 +00:00
|
|
|
} else {
|
2016-11-11 15:00:54 +00:00
|
|
|
logger.error("Unable to init avatar - no id", this);
|
2015-07-20 17:32:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-06-29 14:24:21 +00:00
|
|
|
|
2016-09-19 20:59:56 +00:00
|
|
|
// Determine whether video, avatar or blackness should be displayed
|
|
|
|
let displayMode = this.selectDisplayMode();
|
2016-10-20 19:28:10 +00:00
|
|
|
// Show/hide video.
|
2016-11-29 21:07:18 +00:00
|
|
|
UIUtil.setVisibleBySelector(this.selectVideoElement(),
|
|
|
|
(displayMode === DISPLAY_VIDEO
|
2016-10-27 18:17:17 +00:00
|
|
|
|| displayMode === DISPLAY_VIDEO_WITH_NAME));
|
2016-10-20 19:28:10 +00:00
|
|
|
// Show/hide the avatar.
|
2016-11-29 21:07:18 +00:00
|
|
|
UIUtil.setVisibleBySelector(this.$avatar(),
|
|
|
|
(displayMode === DISPLAY_AVATAR
|
2016-10-27 18:17:17 +00:00
|
|
|
|| displayMode === DISPLAY_AVATAR_WITH_NAME));
|
2016-10-20 19:28:10 +00:00
|
|
|
// Show/hide the display name.
|
2016-11-29 21:07:18 +00:00
|
|
|
UIUtil.setVisibleBySelector(this.$displayName(),
|
|
|
|
!this.hideDisplayName
|
|
|
|
&& (displayMode === DISPLAY_BLACKNESS_WITH_NAME
|
2016-10-27 18:17:17 +00:00
|
|
|
|| displayMode === DISPLAY_VIDEO_WITH_NAME
|
|
|
|
|| displayMode === DISPLAY_AVATAR_WITH_NAME));
|
|
|
|
// show hide overlay when there is a video or avatar under
|
|
|
|
// the display name
|
2016-11-29 21:07:18 +00:00
|
|
|
UIUtil.setVisibleBySelector($('#' + this.videoSpanId
|
2016-10-27 19:32:22 +00:00
|
|
|
+ ' .videocontainer__hoverOverlay'),
|
2016-11-29 21:07:18 +00:00
|
|
|
(displayMode === DISPLAY_AVATAR_WITH_NAME
|
2016-10-27 18:17:17 +00:00
|
|
|
|| displayMode === DISPLAY_VIDEO_WITH_NAME));
|
2015-07-15 10:14:34 +00:00
|
|
|
};
|
2015-06-29 14:24:21 +00:00
|
|
|
|
2016-01-19 23:10:44 +00:00
|
|
|
SmallVideo.prototype.avatarChanged = function (avatarUrl) {
|
2015-06-29 14:24:21 +00:00
|
|
|
var thumbnail = $('#' + this.videoSpanId);
|
2016-09-19 18:57:14 +00:00
|
|
|
var avatarSel = this.$avatar();
|
2015-06-29 14:24:21 +00:00
|
|
|
this.hasAvatar = true;
|
|
|
|
|
|
|
|
// set the avatar in the thumbnail
|
2016-09-19 18:57:14 +00:00
|
|
|
if (avatarSel && avatarSel.length > 0) {
|
|
|
|
avatarSel[0].src = avatarUrl;
|
2015-06-29 14:24:21 +00:00
|
|
|
} else {
|
|
|
|
if (thumbnail && thumbnail.length > 0) {
|
2016-09-19 18:57:14 +00:00
|
|
|
var avatarElement = document.createElement('img');
|
|
|
|
avatarElement.className = 'userAvatar';
|
|
|
|
avatarElement.src = avatarUrl;
|
|
|
|
thumbnail.append(avatarElement);
|
2015-06-29 14:24:21 +00:00
|
|
|
}
|
|
|
|
}
|
2015-07-28 21:52:32 +00:00
|
|
|
};
|
2015-06-29 14:24:21 +00:00
|
|
|
|
2016-02-08 21:41:04 +00:00
|
|
|
/**
|
2016-06-20 21:13:17 +00:00
|
|
|
* Shows or hides the dominant speaker indicator.
|
|
|
|
* @param show whether to show or hide.
|
2016-02-08 21:41:04 +00:00
|
|
|
*/
|
2016-06-20 21:13:17 +00:00
|
|
|
SmallVideo.prototype.showDominantSpeakerIndicator = function (show) {
|
2016-10-10 22:03:28 +00:00
|
|
|
// Don't create and show dominant speaker indicator if
|
|
|
|
// DISABLE_DOMINANT_SPEAKER_INDICATOR is true
|
|
|
|
if (interfaceConfig.DISABLE_DOMINANT_SPEAKER_INDICATOR)
|
|
|
|
return;
|
|
|
|
|
2016-02-08 21:41:04 +00:00
|
|
|
if (!this.container) {
|
2016-11-11 15:00:54 +00:00
|
|
|
logger.warn( "Unable to set dominant speaker indicator - "
|
2016-02-08 21:41:04 +00:00
|
|
|
+ this.videoSpanId + " does not exist");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-10-26 03:05:32 +00:00
|
|
|
let indicatorSpanId = "dominantspeakerindicator";
|
2016-10-26 12:58:27 +00:00
|
|
|
let content = `<i id="indicatoricon"
|
|
|
|
' class="indicatoricon fa fa-bullhorn"></i>`;
|
2016-10-26 03:05:32 +00:00
|
|
|
let indicatorSpan = UIUtil.getVideoThumbnailIndicatorSpan({
|
|
|
|
videoSpanId: this.videoSpanId,
|
|
|
|
indicatorId: indicatorSpanId,
|
2016-10-26 12:58:27 +00:00
|
|
|
content,
|
2016-10-17 17:00:25 +00:00
|
|
|
tooltip: 'speaker'
|
|
|
|
});
|
2016-02-08 21:41:04 +00:00
|
|
|
|
2016-11-29 21:07:18 +00:00
|
|
|
UIUtil.setVisible(indicatorSpan, show);
|
2016-06-20 21:13:17 +00:00
|
|
|
};
|
2016-02-08 21:41:04 +00:00
|
|
|
|
2016-06-20 21:13:17 +00:00
|
|
|
/**
|
|
|
|
* Shows or hides the raised hand indicator.
|
|
|
|
* @param show whether to show or hide.
|
|
|
|
*/
|
|
|
|
SmallVideo.prototype.showRaisedHandIndicator = function (show) {
|
|
|
|
if (!this.container) {
|
2016-11-11 15:00:54 +00:00
|
|
|
logger.warn( "Unable to raised hand indication - "
|
2016-06-20 21:13:17 +00:00
|
|
|
+ this.videoSpanId + " does not exist");
|
|
|
|
return;
|
2016-02-08 21:41:04 +00:00
|
|
|
}
|
|
|
|
|
2016-10-26 03:05:32 +00:00
|
|
|
let indicatorSpanId = "raisehandindicator";
|
2016-10-26 12:58:27 +00:00
|
|
|
let content = `<i id="indicatoricon"
|
|
|
|
class="icon-raised-hand indicatoricon"></i>`;
|
2016-10-26 03:05:32 +00:00
|
|
|
let indicatorSpan = UIUtil.getVideoThumbnailIndicatorSpan({
|
|
|
|
indicatorId: indicatorSpanId,
|
|
|
|
videoSpanId: this.videoSpanId,
|
2016-10-26 12:58:27 +00:00
|
|
|
content,
|
2016-10-17 17:00:25 +00:00
|
|
|
tooltip: 'raisedHand'
|
|
|
|
});
|
2016-06-20 21:13:17 +00:00
|
|
|
|
2016-11-29 21:07:18 +00:00
|
|
|
UIUtil.setVisible(indicatorSpan, show);
|
2016-02-08 21:41:04 +00:00
|
|
|
};
|
|
|
|
|
2016-07-08 20:14:49 +00:00
|
|
|
/**
|
|
|
|
* Adds a listener for onresize events for this video, which will monitor for
|
|
|
|
* resolution changes, will calculate the delay since the moment the listened
|
|
|
|
* is added, and will fire a RESOLUTION_CHANGED event.
|
|
|
|
*/
|
|
|
|
SmallVideo.prototype.waitForResolutionChange = function() {
|
|
|
|
let beforeChange = window.performance.now();
|
|
|
|
let videos = this.selectVideoElement();
|
|
|
|
if (!videos || !videos.length || videos.length <= 0)
|
|
|
|
return;
|
|
|
|
let video = videos[0];
|
|
|
|
let oldWidth = video.videoWidth;
|
|
|
|
let oldHeight = video.videoHeight;
|
2016-10-03 16:12:04 +00:00
|
|
|
video.onresize = () => {
|
2016-07-08 20:14:49 +00:00
|
|
|
if (video.videoWidth != oldWidth || video.videoHeight != oldHeight) {
|
|
|
|
// Only run once.
|
|
|
|
video.onresize = null;
|
|
|
|
|
|
|
|
let delay = window.performance.now() - beforeChange;
|
2016-10-03 16:12:04 +00:00
|
|
|
let emitter = this.VideoLayout.getEventEmitter();
|
2016-07-08 20:14:49 +00:00
|
|
|
if (emitter) {
|
|
|
|
emitter.emit(
|
|
|
|
UIEvents.RESOLUTION_CHANGED,
|
2016-10-03 16:12:04 +00:00
|
|
|
this.getId(),
|
2016-07-08 20:14:49 +00:00
|
|
|
oldWidth + "x" + oldHeight,
|
|
|
|
video.videoWidth + "x" + video.videoHeight,
|
|
|
|
delay);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-08-08 22:03:00 +00:00
|
|
|
/**
|
|
|
|
* Initalizes any browser specific properties. Currently sets the overflow
|
|
|
|
* property for Qt browsers on Windows to hidden, thus fixing the following
|
|
|
|
* problem:
|
|
|
|
* Some browsers don't have full support of the object-fit property for the
|
|
|
|
* video element and when we set video object-fit to "cover" the video
|
|
|
|
* actually overflows the boundaries of its container, so it's important
|
|
|
|
* to indicate that the "overflow" should be hidden.
|
|
|
|
*
|
|
|
|
* Setting this property for all browsers will result in broken audio levels,
|
|
|
|
* which makes this a temporary solution, before reworking audio levels.
|
|
|
|
*/
|
|
|
|
SmallVideo.prototype.initBrowserSpecificProperties = function() {
|
|
|
|
|
|
|
|
var userAgent = window.navigator.userAgent;
|
|
|
|
if (userAgent.indexOf("QtWebEngine") > -1
|
2016-08-22 21:31:20 +00:00
|
|
|
&& (userAgent.indexOf("Windows") > -1
|
|
|
|
|| userAgent.indexOf("Linux") > -1)) {
|
2016-08-08 22:03:00 +00:00
|
|
|
$('#' + this.videoSpanId).css("overflow", "hidden");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-12-14 12:26:50 +00:00
|
|
|
export default SmallVideo;
|