Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

RemoteVideo.js 23KB

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