您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

RemoteVideo.js 24KB

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