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

RemoteVideo.js 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  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. this.removeAvatar();
  457. // Make sure that the large video is updated if are removing its
  458. // corresponding small video.
  459. this.VideoLayout.updateAfterThumbRemoved(this.id);
  460. // Remove whole container
  461. if (this.container.parentNode) {
  462. this.container.parentNode.removeChild(this.container);
  463. }
  464. };
  465. RemoteVideo.prototype.waitForPlayback = function (streamElement, stream) {
  466. var webRtcStream = stream.getOriginalStream();
  467. var isVideo = stream.isVideoTrack();
  468. if (!isVideo || webRtcStream.id === 'mixedmslabel') {
  469. return;
  470. }
  471. var self = this;
  472. // Triggers when video playback starts
  473. var onPlayingHandler = function () {
  474. self.wasVideoPlayed = true;
  475. self.VideoLayout.remoteVideoActive(streamElement, self.id);
  476. streamElement.onplaying = null;
  477. // Refresh to show the video
  478. self.updateView();
  479. };
  480. streamElement.onplaying = onPlayingHandler;
  481. };
  482. /**
  483. * Checks whether the video stream has started for this RemoteVideo instance.
  484. *
  485. * @returns {boolean} true if this RemoteVideo has a video stream for which
  486. * the playback has been started.
  487. */
  488. RemoteVideo.prototype.hasVideoStarted = function () {
  489. return this.wasVideoPlayed;
  490. };
  491. RemoteVideo.prototype.addRemoteStreamElement = function (stream) {
  492. if (!this.container) {
  493. return;
  494. }
  495. let isVideo = stream.isVideoTrack();
  496. isVideo ? this.videoStream = stream : this.audioStream = stream;
  497. if (isVideo)
  498. this.setVideoType(stream.videoType);
  499. // Add click handler.
  500. let onClickHandler = (event) => {
  501. let source = event.target || event.srcElement;
  502. // ignore click if it was done in popup menu
  503. if ($(source).parents('.popupmenu').length === 0) {
  504. this.VideoLayout.handleVideoThumbClicked(this.id);
  505. }
  506. // On IE we need to populate this handler on video <object>
  507. // and it does not give event instance as an argument,
  508. // so we check here for methods.
  509. if (event.stopPropagation && event.preventDefault) {
  510. event.stopPropagation();
  511. event.preventDefault();
  512. }
  513. return false;
  514. };
  515. this.container.onclick = onClickHandler;
  516. if(!stream.getOriginalStream())
  517. return;
  518. let streamElement = SmallVideo.createStreamElement(stream);
  519. // Put new stream element always in front
  520. UIUtils.prependChild(this.container, streamElement);
  521. // If we hide element when Temasys plugin is used then
  522. // we'll never receive 'onplay' event and other logic won't work as expected
  523. // NOTE: hiding will not have effect when Temasys plugin is in use, as
  524. // calling attach will show it back
  525. $(streamElement).hide();
  526. // If the container is currently visible
  527. // we attach the stream to the element.
  528. if (!isVideo || (this.container.offsetParent !== null && isVideo)) {
  529. this.waitForPlayback(streamElement, stream);
  530. streamElement = stream.attach(streamElement);
  531. }
  532. $(streamElement).click(onClickHandler);
  533. if (!isVideo) {
  534. this._audioStreamElement = streamElement;
  535. }
  536. };
  537. RemoteVideo.prototype.updateResolution = function (resolution) {
  538. this.updateConnectionIndicator({ resolution });
  539. };
  540. /**
  541. * Updates this video framerate indication.
  542. * @param framerate the value to update
  543. */
  544. RemoteVideo.prototype.updateFramerate = function (framerate) {
  545. this.updateConnectionIndicator({ framerate });
  546. };
  547. /**
  548. * Sets the display name for the given video span id.
  549. *
  550. * @param displayName the display name to set
  551. */
  552. RemoteVideo.prototype.setDisplayName = function(displayName) {
  553. if (!this.container) {
  554. logger.warn( "Unable to set displayName - " + this.videoSpanId +
  555. " does not exist");
  556. return;
  557. }
  558. this.updateDisplayName({
  559. displayName: displayName || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME,
  560. elementID: `${this.videoSpanId}_name`,
  561. participantID: this.id
  562. });
  563. };
  564. /**
  565. * Removes remote video menu element from video element identified by
  566. * given <tt>videoElementId</tt>.
  567. *
  568. * @param videoElementId the id of local or remote video element.
  569. */
  570. RemoteVideo.prototype.removeRemoteVideoMenu = function() {
  571. var menuSpan = $('#' + this.videoSpanId + '> .remotevideomenu');
  572. if (menuSpan.length) {
  573. this.popover.forceHide();
  574. menuSpan.remove();
  575. this.hasRemoteVideoMenu = false;
  576. }
  577. };
  578. RemoteVideo.createContainer = function (spanId) {
  579. let container = document.createElement('span');
  580. container.id = spanId;
  581. container.className = 'videocontainer';
  582. let wrapper = document.createElement('div');
  583. wrapper.className = 'videocontainer__background';
  584. container.appendChild(wrapper);
  585. let indicatorBar = document.createElement('div');
  586. indicatorBar.className = "videocontainer__toptoolbar";
  587. container.appendChild(indicatorBar);
  588. const connectionIndicatorContainer = document.createElement('span');
  589. connectionIndicatorContainer.className = 'connection-indicator-container';
  590. indicatorBar.appendChild(connectionIndicatorContainer);
  591. let toolbar = document.createElement('div');
  592. toolbar.className = "videocontainer__toolbar";
  593. container.appendChild(toolbar);
  594. let overlay = document.createElement('div');
  595. overlay.className = "videocontainer__hoverOverlay";
  596. container.appendChild(overlay);
  597. const displayNameContainer = document.createElement('div');
  598. displayNameContainer.className = 'displayNameContainer';
  599. container.appendChild(displayNameContainer);
  600. const avatarContainer = document.createElement('div');
  601. avatarContainer.className = 'avatar-container';
  602. container.appendChild(avatarContainer);
  603. var remotes = document.getElementById('filmstripRemoteVideosContainer');
  604. return remotes.appendChild(container);
  605. };
  606. /**
  607. * Shows 2 button dialog for confirmation from the user for muting remote
  608. * participant.
  609. */
  610. RemoteVideo.showMuteParticipantDialog = function () {
  611. return new Promise(resolve => {
  612. APP.UI.messageHandler.openTwoButtonDialog({
  613. titleKey : "dialog.muteParticipantTitle",
  614. msgString: "<div data-i18n='dialog.muteParticipantBody'></div>",
  615. leftButtonKey: "dialog.muteParticipantButton",
  616. dontShowAgain: {
  617. id: "dontShowMuteParticipantDialog",
  618. textKey: "dialog.doNotShowMessageAgain",
  619. checked: true,
  620. buttonValues: [true]
  621. },
  622. submitFunction: () => resolve(MUTED_DIALOG_BUTTON_VALUES.muted),
  623. closeFunction: () => resolve(MUTED_DIALOG_BUTTON_VALUES.cancel)
  624. });
  625. });
  626. };
  627. export default RemoteVideo;