You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RemoteVideo.js 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. /* global $, APP, interfaceConfig, JitsiMeetJS */
  2. /* eslint-disable no-unused-vars */
  3. import React from 'react';
  4. import ReactDOM from 'react-dom';
  5. import {
  6. MuteButton,
  7. KickButton,
  8. REMOTE_CONTROL_MENU_STATES,
  9. RemoteControlButton,
  10. RemoteVideoMenu,
  11. VolumeSlider
  12. } from '../../../react/features/remote-video-menu';
  13. /* eslint-enable no-unused-vars */
  14. const logger = require("jitsi-meet-logger").getLogger(__filename);
  15. import SmallVideo from "./SmallVideo";
  16. import UIUtils from "../util/UIUtil";
  17. import UIEvents from '../../../service/UI/UIEvents';
  18. import JitsiPopover from "../util/JitsiPopover";
  19. const MUTED_DIALOG_BUTTON_VALUES = {
  20. cancel: 0,
  21. muted: 1
  22. };
  23. const ParticipantConnectionStatus
  24. = JitsiMeetJS.constants.participantConnectionStatus;
  25. /**
  26. * Creates new instance of the <tt>RemoteVideo</tt>.
  27. * @param user {JitsiParticipant} the user for whom remote video instance will
  28. * be created.
  29. * @param {VideoLayout} VideoLayout the video layout instance.
  30. * @param {EventEmitter} emitter the event emitter which will be used by
  31. * the new instance to emit events.
  32. * @constructor
  33. */
  34. function RemoteVideo(user, VideoLayout, emitter) {
  35. this.user = user;
  36. this.id = user.getId();
  37. this.emitter = emitter;
  38. this.videoSpanId = `participant_${this.id}`;
  39. SmallVideo.call(this, VideoLayout);
  40. this._audioStreamElement = null;
  41. this.hasRemoteVideoMenu = false;
  42. this._supportsRemoteControl = false;
  43. this.addRemoteVideoContainer();
  44. this.updateConnectionIndicator();
  45. this.setDisplayName();
  46. this.bindHoverHandler();
  47. this.flipX = false;
  48. this.isLocal = false;
  49. this.popupMenuIsHovered = false;
  50. /**
  51. * The flag is set to <tt>true</tt> after the 'onplay' event has been
  52. * triggered on the current video element. It goes back to <tt>false</tt>
  53. * when the stream is removed. It is used to determine whether the video
  54. * playback has ever started.
  55. * @type {boolean}
  56. */
  57. this.wasVideoPlayed = false;
  58. /**
  59. * The flag is set to <tt>true</tt> if remote participant's video gets muted
  60. * during his media connection disruption. This is to prevent black video
  61. * being render on the thumbnail, because even though once the video has
  62. * been played the image usually remains on the video element it seems that
  63. * after longer period of the video element being hidden this image can be
  64. * lost.
  65. * @type {boolean}
  66. */
  67. this.mutedWhileDisconnected = false;
  68. // Bind event handlers so they are only bound once for every instance.
  69. // TODO The event handlers should be turned into actions so changes can be
  70. // handled through reducers and middleware.
  71. this._kickHandler = this._kickHandler.bind(this);
  72. this._muteHandler = this._muteHandler.bind(this);
  73. this._requestRemoteControlPermissions
  74. = this._requestRemoteControlPermissions.bind(this);
  75. this._setAudioVolume = this._setAudioVolume.bind(this);
  76. this._stopRemoteControl = this._stopRemoteControl.bind(this);
  77. }
  78. RemoteVideo.prototype = Object.create(SmallVideo.prototype);
  79. RemoteVideo.prototype.constructor = RemoteVideo;
  80. RemoteVideo.prototype.addRemoteVideoContainer = function() {
  81. this.container = RemoteVideo.createContainer(this.videoSpanId);
  82. this.initBrowserSpecificProperties();
  83. if (APP.conference.isModerator || this._supportsRemoteControl) {
  84. this.addRemoteVideoMenu();
  85. }
  86. this.VideoLayout.resizeThumbnails(false, true);
  87. this.addAudioLevelIndicator();
  88. return this.container;
  89. };
  90. /**
  91. * Initializes the remote participant popup menu, by specifying previously
  92. * constructed popupMenuElement, containing all the menu items.
  93. *
  94. * @param popupMenuElement a pre-constructed element, containing the menu items
  95. * to display in the popup
  96. */
  97. RemoteVideo.prototype._initPopupMenu = function (popupMenuElement) {
  98. let options = {
  99. content: popupMenuElement.outerHTML,
  100. skin: "black",
  101. hasArrow: false,
  102. position: interfaceConfig.VERTICAL_FILMSTRIP ? 'left' : 'top'
  103. };
  104. let element = $("#" + this.videoSpanId + " .remotevideomenu");
  105. this.popover = new JitsiPopover(element, options);
  106. this.popover.addOnHoverPopover(isHovered => {
  107. this.popupMenuIsHovered = isHovered;
  108. this.updateView();
  109. });
  110. // override popover show method to make sure we will update the content
  111. // before showing the popover
  112. let origShowFunc = this.popover.show;
  113. this.popover.show = function () {
  114. // update content by forcing it, to finish even if popover
  115. // is not visible
  116. this.updateRemoteVideoMenu(this.isAudioMuted, true);
  117. // call the original show, passing its actual this
  118. origShowFunc.call(this.popover);
  119. }.bind(this);
  120. };
  121. /**
  122. * Checks whether current video is considered hovered. Currently it is hovered
  123. * if the mouse is over the video, or if the connection indicator or the popup
  124. * menu is shown(hovered).
  125. * @private
  126. * NOTE: extends SmallVideo's method
  127. */
  128. RemoteVideo.prototype._isHovered = function () {
  129. let isHovered = SmallVideo.prototype._isHovered.call(this)
  130. || this.popupMenuIsHovered;
  131. return isHovered;
  132. };
  133. /**
  134. * Generates the popup menu content.
  135. *
  136. * @returns {Element|*} the constructed element, containing popup menu items
  137. * @private
  138. */
  139. RemoteVideo.prototype._generatePopupContent = function () {
  140. const { controller } = APP.remoteControl;
  141. let remoteControlState = null;
  142. let onRemoteControlToggle;
  143. if (this._supportsRemoteControl) {
  144. if (controller.getRequestedParticipant() === this.id) {
  145. onRemoteControlToggle = () => {};
  146. remoteControlState = REMOTE_CONTROL_MENU_STATES.REQUESTING;
  147. } else if (!controller.isStarted()) {
  148. onRemoteControlToggle = this._requestRemoteControlPermissions;
  149. remoteControlState = REMOTE_CONTROL_MENU_STATES.NOT_STARTED;
  150. } else {
  151. onRemoteControlToggle = this._stopRemoteControl;
  152. remoteControlState = REMOTE_CONTROL_MENU_STATES.STARTED;
  153. }
  154. }
  155. let initialVolumeValue, onVolumeChange;
  156. // Feature check for volume setting as temasys objects cannot adjust volume.
  157. if (this._canSetAudioVolume()) {
  158. initialVolumeValue = this._getAudioElement().volume;
  159. onVolumeChange = this._setAudioVolume;
  160. }
  161. const { isModerator } = APP.conference;
  162. const participantID = this.id;
  163. /* jshint ignore:start */
  164. return (
  165. <RemoteVideoMenu id = { participantID }>
  166. { isModerator
  167. ? <MuteButton
  168. isAudioMuted = { this.isAudioMuted }
  169. onClick = { this._muteHandler }
  170. participantID = { participantID } />
  171. : null }
  172. { isModerator
  173. ? <KickButton
  174. onClick = { this._kickHandler }
  175. participantID = { participantID } />
  176. : null }
  177. { remoteControlState
  178. ? <RemoteControlButton
  179. onClick = { onRemoteControlToggle }
  180. participantID = { participantID }
  181. remoteControlState = { remoteControlState } />
  182. : null }
  183. { onVolumeChange
  184. ? <VolumeSlider
  185. initialValue = { initialVolumeValue }
  186. onChange = { onVolumeChange } />
  187. : null }
  188. </RemoteVideoMenu>
  189. );
  190. /* jshint ignore:end */
  191. };
  192. /**
  193. * Sets the remote control supported value and initializes or updates the menu
  194. * depending on the remote control is supported or not.
  195. * @param {boolean} isSupported
  196. */
  197. RemoteVideo.prototype.setRemoteControlSupport = function(isSupported = false) {
  198. if(this._supportsRemoteControl === isSupported) {
  199. return;
  200. }
  201. this._supportsRemoteControl = isSupported;
  202. if(!isSupported) {
  203. return;
  204. }
  205. if(!this.hasRemoteVideoMenu) {
  206. //create menu
  207. this.addRemoteVideoMenu();
  208. } else {
  209. //update the content
  210. this.updateRemoteVideoMenu(this.isAudioMuted, true);
  211. }
  212. };
  213. /**
  214. * Requests permissions for remote control session.
  215. */
  216. RemoteVideo.prototype._requestRemoteControlPermissions = function () {
  217. APP.remoteControl.controller.requestPermissions(
  218. this.id, this.VideoLayout.getLargeVideoWrapper()).then(result => {
  219. if(result === null) {
  220. return;
  221. }
  222. this.updateRemoteVideoMenu(this.isAudioMuted, true);
  223. APP.UI.messageHandler.openMessageDialog(
  224. "dialog.remoteControlTitle",
  225. (result === false) ? "dialog.remoteControlDeniedMessage"
  226. : "dialog.remoteControlAllowedMessage",
  227. {user: this.user.getDisplayName()
  228. || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME}
  229. );
  230. if(result === true) {//the remote control permissions has been granted
  231. // pin the controlled participant
  232. let pinnedId = this.VideoLayout.getPinnedId();
  233. if(pinnedId !== this.id) {
  234. this.VideoLayout.handleVideoThumbClicked(this.id);
  235. }
  236. }
  237. }, error => {
  238. logger.error(error);
  239. this.updateRemoteVideoMenu(this.isAudioMuted, true);
  240. APP.UI.messageHandler.openMessageDialog(
  241. "dialog.remoteControlTitle",
  242. "dialog.remoteControlErrorMessage",
  243. {user: this.user.getDisplayName()
  244. || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME}
  245. );
  246. });
  247. this.updateRemoteVideoMenu(this.isAudioMuted, true);
  248. };
  249. /**
  250. * Stops remote control session.
  251. */
  252. RemoteVideo.prototype._stopRemoteControl = function () {
  253. // send message about stopping
  254. APP.remoteControl.controller.stop();
  255. this.updateRemoteVideoMenu(this.isAudioMuted, true);
  256. };
  257. RemoteVideo.prototype._muteHandler = function () {
  258. if (this.isAudioMuted)
  259. return;
  260. RemoteVideo.showMuteParticipantDialog().then(reason => {
  261. if(reason === MUTED_DIALOG_BUTTON_VALUES.muted) {
  262. this.emitter.emit(UIEvents.REMOTE_AUDIO_MUTED, this.id);
  263. }
  264. }).catch(e => {
  265. //currently shouldn't be called
  266. logger.error(e);
  267. });
  268. this.popover.forceHide();
  269. };
  270. RemoteVideo.prototype._kickHandler = function () {
  271. this.emitter.emit(UIEvents.USER_KICKED, this.id);
  272. this.popover.forceHide();
  273. };
  274. /**
  275. * Get the remote participant's audio element.
  276. *
  277. * @returns {Element} audio element
  278. */
  279. RemoteVideo.prototype._getAudioElement = function () {
  280. return this._audioStreamElement;
  281. };
  282. /**
  283. * Check if the remote participant's audio can have its volume adjusted.
  284. *
  285. * @returns {boolean} true if the volume can be adjusted.
  286. */
  287. RemoteVideo.prototype._canSetAudioVolume = function () {
  288. const audioElement = this._getAudioElement();
  289. return audioElement && audioElement.volume !== undefined;
  290. };
  291. /**
  292. * Change the remote participant's volume level.
  293. *
  294. * @param {int} newVal - The value to set the slider to.
  295. */
  296. RemoteVideo.prototype._setAudioVolume = function (newVal) {
  297. if (this._canSetAudioVolume()) {
  298. this._getAudioElement().volume = newVal;
  299. }
  300. };
  301. /**
  302. * Updates the remote video menu.
  303. *
  304. * @param isMuted the new muted state to update to
  305. * @param force to work even if popover is not visible
  306. */
  307. RemoteVideo.prototype.updateRemoteVideoMenu = function (isMuted, force) {
  308. this.isAudioMuted = isMuted;
  309. if (!this.popover) {
  310. return;
  311. }
  312. // generate content, translate it and add it to document only if
  313. // popover is visible or we force to do so.
  314. if(this.popover.popoverShown || force) {
  315. this.popover.updateContent(this._generatePopupContent());
  316. }
  317. };
  318. /**
  319. * @inheritDoc
  320. * @override
  321. */
  322. RemoteVideo.prototype.setVideoMutedView = function(isMuted) {
  323. SmallVideo.prototype.setVideoMutedView.call(this, isMuted);
  324. // Update 'mutedWhileDisconnected' flag
  325. this._figureOutMutedWhileDisconnected();
  326. };
  327. /**
  328. * Figures out the value of {@link #mutedWhileDisconnected} flag by taking into
  329. * account remote participant's network connectivity and video muted status.
  330. *
  331. * @private
  332. */
  333. RemoteVideo.prototype._figureOutMutedWhileDisconnected = function() {
  334. const isActive = this.isConnectionActive();
  335. if (!isActive && this.isVideoMuted) {
  336. this.mutedWhileDisconnected = true;
  337. } else if (isActive && !this.isVideoMuted) {
  338. this.mutedWhileDisconnected = false;
  339. }
  340. };
  341. /**
  342. * Adds the remote video menu element for the given <tt>id</tt> in the
  343. * given <tt>parentElement</tt>.
  344. *
  345. * @param id the id indicating the video for which we're adding a menu.
  346. * @param parentElement the parent element where this menu will be added
  347. */
  348. RemoteVideo.prototype.addRemoteVideoMenu = function () {
  349. if (interfaceConfig.filmStripOnly) {
  350. return;
  351. }
  352. var spanElement = document.createElement('span');
  353. spanElement.className = 'remotevideomenu';
  354. this.container.appendChild(spanElement);
  355. var menuElement = document.createElement('i');
  356. menuElement.className = 'icon-thumb-menu';
  357. menuElement.title = 'Remote user controls';
  358. spanElement.appendChild(menuElement);
  359. this._initPopupMenu(this._generatePopupContent());
  360. this.hasRemoteVideoMenu = true;
  361. };
  362. /**
  363. * Removes the remote stream element corresponding to the given stream and
  364. * parent container.
  365. *
  366. * @param stream the MediaStream
  367. * @param isVideo <tt>true</tt> if given <tt>stream</tt> is a video one.
  368. */
  369. RemoteVideo.prototype.removeRemoteStreamElement = function (stream) {
  370. if (!this.container)
  371. return false;
  372. var isVideo = stream.isVideoTrack();
  373. var elementID = SmallVideo.getStreamElementID(stream);
  374. var select = $('#' + elementID);
  375. select.remove();
  376. if (isVideo) {
  377. this.wasVideoPlayed = false;
  378. }
  379. logger.info((isVideo ? "Video" : "Audio") +
  380. " removed " + this.id, select);
  381. // when removing only the video element and we are on stage
  382. // update the stage
  383. if (isVideo && this.isCurrentlyOnLargeVideo()) {
  384. this.VideoLayout.updateLargeVideo(this.id);
  385. } else {
  386. // Missing video stream will affect display mode
  387. this.updateView();
  388. }
  389. };
  390. /**
  391. * Checks whether the remote user associated with this <tt>RemoteVideo</tt>
  392. * has connectivity issues.
  393. *
  394. * @return {boolean} <tt>true</tt> if the user's connection is fine or
  395. * <tt>false</tt> otherwise.
  396. */
  397. RemoteVideo.prototype.isConnectionActive = function() {
  398. return this.user.getConnectionStatus()
  399. === ParticipantConnectionStatus.ACTIVE;
  400. };
  401. /**
  402. * The remote video is considered "playable" once the stream has started
  403. * according to the {@link #hasVideoStarted} result.
  404. * It will be allowed to display video also in
  405. * {@link ParticipantConnectionStatus.INTERRUPTED} if the video was ever played
  406. * and was not muted while not in ACTIVE state. This basically means that there
  407. * is stalled video image cached that could be displayed. It's used to show
  408. * "grey video image" in user's thumbnail when there are connectivity issues.
  409. *
  410. * @inheritdoc
  411. * @override
  412. */
  413. RemoteVideo.prototype.isVideoPlayable = function () {
  414. const connectionState
  415. = APP.conference.getParticipantConnectionStatus(this.id);
  416. return SmallVideo.prototype.isVideoPlayable.call(this)
  417. && this.hasVideoStarted()
  418. && (connectionState === ParticipantConnectionStatus.ACTIVE
  419. || (connectionState === ParticipantConnectionStatus.INTERRUPTED
  420. && !this.mutedWhileDisconnected));
  421. };
  422. /**
  423. * @inheritDoc
  424. */
  425. RemoteVideo.prototype.updateView = function () {
  426. $(this.container).toggleClass('audio-only', APP.conference.isAudioOnly());
  427. this.updateConnectionStatusIndicator();
  428. // This must be called after 'updateConnectionStatusIndicator' because it
  429. // affects the display mode by modifying 'mutedWhileDisconnected' flag
  430. SmallVideo.prototype.updateView.call(this);
  431. };
  432. /**
  433. * Updates the UI to reflect user's connectivity status.
  434. */
  435. RemoteVideo.prototype.updateConnectionStatusIndicator = function () {
  436. const connectionStatus = this.user.getConnectionStatus();
  437. logger.debug(`${this.id} thumbnail connection status: ${connectionStatus}`);
  438. // FIXME rename 'mutedWhileDisconnected' to 'mutedWhileNotRendering'
  439. // Update 'mutedWhileDisconnected' flag
  440. this._figureOutMutedWhileDisconnected();
  441. this.updateConnectionStatus(connectionStatus);
  442. const isInterrupted
  443. = connectionStatus === ParticipantConnectionStatus.INTERRUPTED;
  444. // Toggle thumbnail video problem filter
  445. this.selectVideoElement().toggleClass(
  446. "videoThumbnailProblemFilter", isInterrupted);
  447. this.$avatar().toggleClass(
  448. "videoThumbnailProblemFilter", isInterrupted);
  449. };
  450. /**
  451. * Removes RemoteVideo from the page.
  452. */
  453. RemoteVideo.prototype.remove = function () {
  454. logger.log("Remove thumbnail", this.id);
  455. this.removeAudioLevelIndicator();
  456. const toolbarContainer
  457. = this.container.querySelector('.videocontainer__toolbar');
  458. if (toolbarContainer) {
  459. ReactDOM.unmountComponentAtNode(toolbarContainer);
  460. }
  461. this.removeConnectionIndicator();
  462. this.removeDisplayName();
  463. this.removeAvatar();
  464. this._unmountIndicators();
  465. // Make sure that the large video is updated if are removing its
  466. // corresponding small video.
  467. this.VideoLayout.updateAfterThumbRemoved(this.id);
  468. // Remove whole container
  469. if (this.container.parentNode) {
  470. this.container.parentNode.removeChild(this.container);
  471. }
  472. };
  473. RemoteVideo.prototype.waitForPlayback = function (streamElement, stream) {
  474. var webRtcStream = stream.getOriginalStream();
  475. var isVideo = stream.isVideoTrack();
  476. if (!isVideo || webRtcStream.id === 'mixedmslabel') {
  477. return;
  478. }
  479. var self = this;
  480. // Triggers when video playback starts
  481. var onPlayingHandler = function () {
  482. self.wasVideoPlayed = true;
  483. self.VideoLayout.remoteVideoActive(streamElement, self.id);
  484. streamElement.onplaying = null;
  485. // Refresh to show the video
  486. self.updateView();
  487. };
  488. streamElement.onplaying = onPlayingHandler;
  489. };
  490. /**
  491. * Checks whether the video stream has started for this RemoteVideo instance.
  492. *
  493. * @returns {boolean} true if this RemoteVideo has a video stream for which
  494. * the playback has been started.
  495. */
  496. RemoteVideo.prototype.hasVideoStarted = function () {
  497. return this.wasVideoPlayed;
  498. };
  499. RemoteVideo.prototype.addRemoteStreamElement = function (stream) {
  500. if (!this.container) {
  501. return;
  502. }
  503. let isVideo = stream.isVideoTrack();
  504. isVideo ? this.videoStream = stream : this.audioStream = stream;
  505. if (isVideo)
  506. this.setVideoType(stream.videoType);
  507. // Add click handler.
  508. let onClickHandler = (event) => {
  509. let source = event.target || event.srcElement;
  510. // ignore click if it was done in popup menu
  511. if ($(source).parents('.popupmenu').length === 0) {
  512. this.VideoLayout.handleVideoThumbClicked(this.id);
  513. }
  514. // On IE we need to populate this handler on video <object>
  515. // and it does not give event instance as an argument,
  516. // so we check here for methods.
  517. if (event.stopPropagation && event.preventDefault) {
  518. event.stopPropagation();
  519. event.preventDefault();
  520. }
  521. return false;
  522. };
  523. this.container.onclick = onClickHandler;
  524. if(!stream.getOriginalStream())
  525. return;
  526. let streamElement = SmallVideo.createStreamElement(stream);
  527. // Put new stream element always in front
  528. UIUtils.prependChild(this.container, streamElement);
  529. // If we hide element when Temasys plugin is used then
  530. // we'll never receive 'onplay' event and other logic won't work as expected
  531. // NOTE: hiding will not have effect when Temasys plugin is in use, as
  532. // calling attach will show it back
  533. $(streamElement).hide();
  534. // If the container is currently visible
  535. // we attach the stream to the element.
  536. if (!isVideo || (this.container.offsetParent !== null && isVideo)) {
  537. this.waitForPlayback(streamElement, stream);
  538. streamElement = stream.attach(streamElement);
  539. }
  540. $(streamElement).click(onClickHandler);
  541. if (!isVideo) {
  542. this._audioStreamElement = streamElement;
  543. }
  544. };
  545. RemoteVideo.prototype.updateResolution = function (resolution) {
  546. this.updateConnectionIndicator({ resolution });
  547. };
  548. /**
  549. * Updates this video framerate indication.
  550. * @param framerate the value to update
  551. */
  552. RemoteVideo.prototype.updateFramerate = function (framerate) {
  553. this.updateConnectionIndicator({ framerate });
  554. };
  555. /**
  556. * Sets the display name for the given video span id.
  557. *
  558. * @param displayName the display name to set
  559. */
  560. RemoteVideo.prototype.setDisplayName = function(displayName) {
  561. if (!this.container) {
  562. logger.warn( "Unable to set displayName - " + this.videoSpanId +
  563. " does not exist");
  564. return;
  565. }
  566. this.updateDisplayName({
  567. displayName: displayName || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME,
  568. elementID: `${this.videoSpanId}_name`,
  569. participantID: this.id
  570. });
  571. };
  572. /**
  573. * Removes remote video menu element from video element identified by
  574. * given <tt>videoElementId</tt>.
  575. *
  576. * @param videoElementId the id of local or remote video element.
  577. */
  578. RemoteVideo.prototype.removeRemoteVideoMenu = function() {
  579. var menuSpan = $('#' + this.videoSpanId + '> .remotevideomenu');
  580. if (menuSpan.length) {
  581. this.popover.forceHide();
  582. menuSpan.remove();
  583. this.hasRemoteVideoMenu = false;
  584. }
  585. };
  586. RemoteVideo.createContainer = function (spanId) {
  587. let container = document.createElement('span');
  588. container.id = spanId;
  589. container.className = 'videocontainer';
  590. let wrapper = document.createElement('div');
  591. wrapper.className = 'videocontainer__background';
  592. container.appendChild(wrapper);
  593. let indicatorBar = document.createElement('div');
  594. indicatorBar.className = "videocontainer__toptoolbar";
  595. container.appendChild(indicatorBar);
  596. let toolbar = document.createElement('div');
  597. toolbar.className = "videocontainer__toolbar";
  598. container.appendChild(toolbar);
  599. let overlay = document.createElement('div');
  600. overlay.className = "videocontainer__hoverOverlay";
  601. container.appendChild(overlay);
  602. const displayNameContainer = document.createElement('div');
  603. displayNameContainer.className = 'displayNameContainer';
  604. container.appendChild(displayNameContainer);
  605. const avatarContainer = document.createElement('div');
  606. avatarContainer.className = 'avatar-container';
  607. container.appendChild(avatarContainer);
  608. var remotes = document.getElementById('filmstripRemoteVideosContainer');
  609. return remotes.appendChild(container);
  610. };
  611. /**
  612. * Shows 2 button dialog for confirmation from the user for muting remote
  613. * participant.
  614. */
  615. RemoteVideo.showMuteParticipantDialog = function () {
  616. return new Promise(resolve => {
  617. APP.UI.messageHandler.openTwoButtonDialog({
  618. titleKey : "dialog.muteParticipantTitle",
  619. msgString: "<div data-i18n='dialog.muteParticipantBody'></div>",
  620. leftButtonKey: "dialog.muteParticipantButton",
  621. dontShowAgain: {
  622. id: "dontShowMuteParticipantDialog",
  623. textKey: "dialog.doNotShowMessageAgain",
  624. checked: true,
  625. buttonValues: [true]
  626. },
  627. submitFunction: () => resolve(MUTED_DIALOG_BUTTON_VALUES.muted),
  628. closeFunction: () => resolve(MUTED_DIALOG_BUTTON_VALUES.cancel)
  629. });
  630. });
  631. };
  632. export default RemoteVideo;