Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

SmallVideo.js 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868
  1. /* global $, APP, interfaceConfig */
  2. /* eslint-disable no-unused-vars */
  3. import React from 'react';
  4. import ReactDOM from 'react-dom';
  5. import { I18nextProvider } from 'react-i18next';
  6. import { AtlasKitThemeProvider } from '@atlaskit/theme';
  7. import { Provider } from 'react-redux';
  8. import { i18next } from '../../../react/features/base/i18n';
  9. import { AudioLevelIndicator }
  10. from '../../../react/features/audio-level-indicator';
  11. import {
  12. Avatar as AvatarDisplay,
  13. getAvatarURLByParticipantId,
  14. getPinnedParticipant,
  15. pinParticipant
  16. } from '../../../react/features/base/participants';
  17. import {
  18. ConnectionIndicator
  19. } from '../../../react/features/connection-indicator';
  20. import { DisplayName } from '../../../react/features/display-name';
  21. import {
  22. AudioMutedIndicator,
  23. DominantSpeakerIndicator,
  24. ModeratorIndicator,
  25. RaisedHandIndicator,
  26. VideoMutedIndicator
  27. } from '../../../react/features/filmstrip';
  28. import {
  29. LAYOUTS,
  30. getCurrentLayout,
  31. setTileView,
  32. shouldDisplayTileView
  33. } from '../../../react/features/video-layout';
  34. /* eslint-enable no-unused-vars */
  35. const logger = require('jitsi-meet-logger').getLogger(__filename);
  36. import UIUtil from '../util/UIUtil';
  37. import UIEvents from '../../../service/UI/UIEvents';
  38. /**
  39. * Display mode constant used when video is being displayed on the small video.
  40. * @type {number}
  41. * @constant
  42. */
  43. const DISPLAY_VIDEO = 0;
  44. /**
  45. * Display mode constant used when the user's avatar is being displayed on
  46. * the small video.
  47. * @type {number}
  48. * @constant
  49. */
  50. const DISPLAY_AVATAR = 1;
  51. /**
  52. * Display mode constant used when neither video nor avatar is being displayed
  53. * on the small video. And we just show the display name.
  54. * @type {number}
  55. * @constant
  56. */
  57. const DISPLAY_BLACKNESS_WITH_NAME = 2;
  58. /**
  59. * Display mode constant used when video is displayed and display name
  60. * at the same time.
  61. * @type {number}
  62. * @constant
  63. */
  64. const DISPLAY_VIDEO_WITH_NAME = 3;
  65. /**
  66. * Display mode constant used when neither video nor avatar is being displayed
  67. * on the small video. And we just show the display name.
  68. * @type {number}
  69. * @constant
  70. */
  71. const DISPLAY_AVATAR_WITH_NAME = 4;
  72. /**
  73. * Constructor.
  74. */
  75. function SmallVideo(VideoLayout) {
  76. this._isModerator = false;
  77. this.isAudioMuted = false;
  78. this.hasAvatar = false;
  79. this.isVideoMuted = false;
  80. this.videoStream = null;
  81. this.audioStream = null;
  82. this.VideoLayout = VideoLayout;
  83. this.videoIsHovered = false;
  84. // we can stop updating the thumbnail
  85. this.disableUpdateView = false;
  86. /**
  87. * The current state of the user's bridge connection. The value should be
  88. * a string as enumerated in the library's participantConnectionStatus
  89. * constants.
  90. *
  91. * @private
  92. * @type {string|null}
  93. */
  94. this._connectionStatus = null;
  95. /**
  96. * Whether or not the ConnectionIndicator's popover is hovered. Modifies
  97. * how the video overlays display based on hover state.
  98. *
  99. * @private
  100. * @type {boolean}
  101. */
  102. this._popoverIsHovered = false;
  103. /**
  104. * Whether or not the connection indicator should be displayed.
  105. *
  106. * @private
  107. * @type {boolean}
  108. */
  109. this._showConnectionIndicator
  110. = !interfaceConfig.CONNECTION_INDICATOR_DISABLED;
  111. /**
  112. * Whether or not the dominant speaker indicator should be displayed.
  113. *
  114. * @private
  115. * @type {boolean}
  116. */
  117. this._showDominantSpeaker = false;
  118. /**
  119. * Whether or not the raised hand indicator should be displayed.
  120. *
  121. * @private
  122. * @type {boolean}
  123. */
  124. this._showRaisedHand = false;
  125. // Bind event handlers so they are only bound once for every instance.
  126. this._onPopoverHover = this._onPopoverHover.bind(this);
  127. this.updateView = this.updateView.bind(this);
  128. }
  129. /**
  130. * Returns the identifier of this small video.
  131. *
  132. * @returns the identifier of this small video
  133. */
  134. SmallVideo.prototype.getId = function() {
  135. return this.id;
  136. };
  137. /* Indicates if this small video is currently visible.
  138. *
  139. * @return <tt>true</tt> if this small video isn't currently visible and
  140. * <tt>false</tt> - otherwise.
  141. */
  142. SmallVideo.prototype.isVisible = function() {
  143. return this.$container.is(':visible');
  144. };
  145. /**
  146. * Sets the type of the video displayed by this instance.
  147. * Note that this is a string without clearly defined or checked values, and
  148. * it is NOT one of the strings defined in service/RTC/VideoType in
  149. * lib-jitsi-meet.
  150. * @param videoType 'camera' or 'desktop', or 'sharedvideo'.
  151. */
  152. SmallVideo.prototype.setVideoType = function(videoType) {
  153. this.videoType = videoType;
  154. };
  155. /**
  156. * Returns the type of the video displayed by this instance.
  157. * Note that this is a string without clearly defined or checked values, and
  158. * it is NOT one of the strings defined in service/RTC/VideoType in
  159. * lib-jitsi-meet.
  160. * @returns {String} 'camera', 'screen', 'sharedvideo', or undefined.
  161. */
  162. SmallVideo.prototype.getVideoType = function() {
  163. return this.videoType;
  164. };
  165. /**
  166. * Creates an audio or video element for a particular MediaStream.
  167. */
  168. SmallVideo.createStreamElement = function(stream) {
  169. const isVideo = stream.isVideoTrack();
  170. const element = isVideo
  171. ? document.createElement('video')
  172. : document.createElement('audio');
  173. if (isVideo) {
  174. element.setAttribute('muted', 'true');
  175. }
  176. element.autoplay = true;
  177. element.id = SmallVideo.getStreamElementID(stream);
  178. return element;
  179. };
  180. /**
  181. * Returns the element id for a particular MediaStream.
  182. */
  183. SmallVideo.getStreamElementID = function(stream) {
  184. const isVideo = stream.isVideoTrack();
  185. return (isVideo ? 'remoteVideo_' : 'remoteAudio_') + stream.getId();
  186. };
  187. /**
  188. * Configures hoverIn/hoverOut handlers. Depends on connection indicator.
  189. */
  190. SmallVideo.prototype.bindHoverHandler = function() {
  191. // Add hover handler
  192. this.$container.hover(
  193. () => {
  194. this.videoIsHovered = true;
  195. this.updateView();
  196. this.updateIndicators();
  197. },
  198. () => {
  199. this.videoIsHovered = false;
  200. this.updateView();
  201. this.updateIndicators();
  202. }
  203. );
  204. };
  205. /**
  206. * Unmounts the ConnectionIndicator component.
  207. * @returns {void}
  208. */
  209. SmallVideo.prototype.removeConnectionIndicator = function() {
  210. this._showConnectionIndicator = false;
  211. this.updateIndicators();
  212. };
  213. /**
  214. * Updates the connectionStatus stat which displays in the ConnectionIndicator.
  215. * @returns {void}
  216. */
  217. SmallVideo.prototype.updateConnectionStatus = function(connectionStatus) {
  218. this._connectionStatus = connectionStatus;
  219. this.updateIndicators();
  220. };
  221. /**
  222. * Shows / hides the audio muted indicator over small videos.
  223. *
  224. * @param {boolean} isMuted indicates if the muted element should be shown
  225. * or hidden
  226. */
  227. SmallVideo.prototype.showAudioIndicator = function(isMuted) {
  228. this.isAudioMuted = isMuted;
  229. this.updateStatusBar();
  230. };
  231. /**
  232. * Shows video muted indicator over small videos and disables/enables avatar
  233. * if video muted.
  234. *
  235. * @param {boolean} isMuted indicates if we should set the view to muted view
  236. * or not
  237. */
  238. SmallVideo.prototype.setVideoMutedView = function(isMuted) {
  239. this.isVideoMuted = isMuted;
  240. this.updateView();
  241. this.updateStatusBar();
  242. };
  243. /**
  244. * Create or updates the ReactElement for displaying status indicators about
  245. * audio mute, video mute, and moderator status.
  246. *
  247. * @returns {void}
  248. */
  249. SmallVideo.prototype.updateStatusBar = function() {
  250. const statusBarContainer
  251. = this.container.querySelector('.videocontainer__toolbar');
  252. if (!statusBarContainer) {
  253. return;
  254. }
  255. const currentLayout = getCurrentLayout(APP.store.getState());
  256. let tooltipPosition;
  257. if (currentLayout === LAYOUTS.TILE_VIEW) {
  258. tooltipPosition = 'right';
  259. } else if (currentLayout === LAYOUTS.VERTICAL_FILMSTRIP_VIEW) {
  260. tooltipPosition = 'left';
  261. } else {
  262. tooltipPosition = 'top';
  263. }
  264. ReactDOM.render(
  265. <I18nextProvider i18n = { i18next }>
  266. <div>
  267. { this.isAudioMuted
  268. ? <AudioMutedIndicator
  269. tooltipPosition = { tooltipPosition } />
  270. : null }
  271. { this.isVideoMuted
  272. ? <VideoMutedIndicator
  273. tooltipPosition = { tooltipPosition } />
  274. : null }
  275. { this._isModerator && !interfaceConfig.DISABLE_FOCUS_INDICATOR
  276. ? <ModeratorIndicator
  277. tooltipPosition = { tooltipPosition } />
  278. : null }
  279. </div>
  280. </I18nextProvider>,
  281. statusBarContainer);
  282. };
  283. /**
  284. * Adds the element indicating the moderator(owner) of the conference.
  285. */
  286. SmallVideo.prototype.addModeratorIndicator = function() {
  287. this._isModerator = true;
  288. this.updateStatusBar();
  289. };
  290. /**
  291. * Adds the element indicating the audio level of the participant.
  292. *
  293. * @returns {void}
  294. */
  295. SmallVideo.prototype.addAudioLevelIndicator = function() {
  296. let audioLevelContainer = this._getAudioLevelContainer();
  297. if (audioLevelContainer) {
  298. return;
  299. }
  300. audioLevelContainer = document.createElement('span');
  301. audioLevelContainer.className = 'audioindicator-container';
  302. this.container.appendChild(audioLevelContainer);
  303. this.updateAudioLevelIndicator();
  304. };
  305. /**
  306. * Removes the element indicating the audio level of the participant.
  307. *
  308. * @returns {void}
  309. */
  310. SmallVideo.prototype.removeAudioLevelIndicator = function() {
  311. const audioLevelContainer = this._getAudioLevelContainer();
  312. if (audioLevelContainer) {
  313. ReactDOM.unmountComponentAtNode(audioLevelContainer);
  314. }
  315. };
  316. /**
  317. * Updates the audio level for this small video.
  318. *
  319. * @param lvl the new audio level to set
  320. * @returns {void}
  321. */
  322. SmallVideo.prototype.updateAudioLevelIndicator = function(lvl = 0) {
  323. const audioLevelContainer = this._getAudioLevelContainer();
  324. if (audioLevelContainer) {
  325. ReactDOM.render(
  326. <AudioLevelIndicator
  327. audioLevel = { lvl }/>,
  328. audioLevelContainer);
  329. }
  330. };
  331. /**
  332. * Queries the component's DOM for the element that should be the parent to the
  333. * AudioLevelIndicator.
  334. *
  335. * @returns {HTMLElement} The DOM element that holds the AudioLevelIndicator.
  336. */
  337. SmallVideo.prototype._getAudioLevelContainer = function() {
  338. return this.container.querySelector('.audioindicator-container');
  339. };
  340. /**
  341. * Removes the element indicating the moderator(owner) of the conference.
  342. */
  343. SmallVideo.prototype.removeModeratorIndicator = function() {
  344. this._isModerator = false;
  345. this.updateStatusBar();
  346. };
  347. /**
  348. * This is an especially interesting function. A naive reader might think that
  349. * it returns this SmallVideo's "video" element. But it is much more exciting.
  350. * It first finds this video's parent element using jquery, then uses a utility
  351. * from lib-jitsi-meet to extract the video element from it (with two more
  352. * jquery calls), and finally uses jquery again to encapsulate the video element
  353. * in an array. This last step allows (some might prefer "forces") users of
  354. * this function to access the video element via the 0th element of the returned
  355. * array (after checking its length of course!).
  356. */
  357. SmallVideo.prototype.selectVideoElement = function() {
  358. return $($(this.container).find('video')[0]);
  359. };
  360. /**
  361. * Selects the HTML image element which displays user's avatar.
  362. *
  363. * @return {jQuery|HTMLElement} a jQuery selector pointing to the HTML image
  364. * element which displays the user's avatar.
  365. */
  366. SmallVideo.prototype.$avatar = function() {
  367. return this.$container.find('.avatar-container');
  368. };
  369. /**
  370. * Returns the display name element, which appears on the video thumbnail.
  371. *
  372. * @return {jQuery} a jQuery selector pointing to the display name element of
  373. * the video thumbnail
  374. */
  375. SmallVideo.prototype.$displayName = function() {
  376. return this.$container.find('.displayNameContainer');
  377. };
  378. /**
  379. * Creates or updates the participant's display name that is shown over the
  380. * video preview.
  381. *
  382. * @returns {void}
  383. */
  384. SmallVideo.prototype.updateDisplayName = function(props) {
  385. const displayNameContainer
  386. = this.container.querySelector('.displayNameContainer');
  387. if (displayNameContainer) {
  388. ReactDOM.render(
  389. <Provider store = { APP.store }>
  390. <I18nextProvider i18n = { i18next }>
  391. <DisplayName { ...props } />
  392. </I18nextProvider>
  393. </Provider>,
  394. displayNameContainer);
  395. }
  396. };
  397. /**
  398. * Removes the component responsible for showing the participant's display name,
  399. * if its container is present.
  400. *
  401. * @returns {void}
  402. */
  403. SmallVideo.prototype.removeDisplayName = function() {
  404. const displayNameContainer
  405. = this.container.querySelector('.displayNameContainer');
  406. if (displayNameContainer) {
  407. ReactDOM.unmountComponentAtNode(displayNameContainer);
  408. }
  409. };
  410. /**
  411. * Enables / disables the css responsible for focusing/pinning a video
  412. * thumbnail.
  413. *
  414. * @param isFocused indicates if the thumbnail should be focused/pinned or not
  415. */
  416. SmallVideo.prototype.focus = function(isFocused) {
  417. const focusedCssClass = 'videoContainerFocused';
  418. const isFocusClassEnabled = this.$container.hasClass(focusedCssClass);
  419. if (!isFocused && isFocusClassEnabled) {
  420. this.$container.removeClass(focusedCssClass);
  421. } else if (isFocused && !isFocusClassEnabled) {
  422. this.$container.addClass(focusedCssClass);
  423. }
  424. };
  425. SmallVideo.prototype.hasVideo = function() {
  426. return this.selectVideoElement().length !== 0;
  427. };
  428. /**
  429. * Checks whether the user associated with this <tt>SmallVideo</tt> is currently
  430. * being displayed on the "large video".
  431. *
  432. * @return {boolean} <tt>true</tt> if the user is displayed on the large video
  433. * or <tt>false</tt> otherwise.
  434. */
  435. SmallVideo.prototype.isCurrentlyOnLargeVideo = function() {
  436. return this.VideoLayout.isCurrentlyOnLarge(this.id);
  437. };
  438. /**
  439. * Checks whether there is a playable video stream available for the user
  440. * associated with this <tt>SmallVideo</tt>.
  441. *
  442. * @return {boolean} <tt>true</tt> if there is a playable video stream available
  443. * or <tt>false</tt> otherwise.
  444. */
  445. SmallVideo.prototype.isVideoPlayable = function() {
  446. return this.videoStream // Is there anything to display ?
  447. && !this.isVideoMuted && !this.videoStream.isMuted(); // Muted ?
  448. };
  449. /**
  450. * Determines what should be display on the thumbnail.
  451. *
  452. * @return {number} one of <tt>DISPLAY_VIDEO</tt>,<tt>DISPLAY_AVATAR</tt>
  453. * or <tt>DISPLAY_BLACKNESS_WITH_NAME</tt>.
  454. */
  455. SmallVideo.prototype.selectDisplayMode = function() {
  456. // Display name is always and only displayed when user is on the stage
  457. if (this.isCurrentlyOnLargeVideo()
  458. && !shouldDisplayTileView(APP.store.getState())) {
  459. return this.isVideoPlayable() && !APP.conference.isAudioOnly()
  460. ? DISPLAY_BLACKNESS_WITH_NAME : DISPLAY_AVATAR_WITH_NAME;
  461. } else if (this.isVideoPlayable()
  462. && this.selectVideoElement().length
  463. && !APP.conference.isAudioOnly()) {
  464. // check hovering and change state to video with name
  465. return this._isHovered()
  466. ? DISPLAY_VIDEO_WITH_NAME : DISPLAY_VIDEO;
  467. }
  468. // check hovering and change state to avatar with name
  469. return this._isHovered()
  470. ? DISPLAY_AVATAR_WITH_NAME : DISPLAY_AVATAR;
  471. };
  472. /**
  473. * Checks whether current video is considered hovered. Currently it is hovered
  474. * if the mouse is over the video, or if the connection
  475. * indicator is shown(hovered).
  476. * @private
  477. */
  478. SmallVideo.prototype._isHovered = function() {
  479. return this.videoIsHovered || this._popoverIsHovered;
  480. };
  481. /**
  482. * Hides or shows the user's avatar.
  483. * This update assumes that large video had been updated and we will
  484. * reflect it on this small video.
  485. *
  486. * @param show whether we should show the avatar or not
  487. * video because there is no dominant speaker and no focused speaker
  488. */
  489. SmallVideo.prototype.updateView = function() {
  490. if (this.disableUpdateView) {
  491. return;
  492. }
  493. if (!this.hasAvatar) {
  494. if (this.id) {
  495. // Init avatar
  496. this.avatarChanged(
  497. getAvatarURLByParticipantId(APP.store.getState(), this.id));
  498. } else {
  499. logger.error('Unable to init avatar - no id', this);
  500. return;
  501. }
  502. }
  503. this.$container.removeClass((index, classNames) =>
  504. classNames.split(' ').filter(name => name.startsWith('display-')));
  505. // Determine whether video, avatar or blackness should be displayed
  506. const displayMode = this.selectDisplayMode();
  507. switch (displayMode) {
  508. case DISPLAY_AVATAR_WITH_NAME:
  509. this.$container.addClass('display-avatar-with-name');
  510. break;
  511. case DISPLAY_BLACKNESS_WITH_NAME:
  512. this.$container.addClass('display-name-on-black');
  513. break;
  514. case DISPLAY_VIDEO:
  515. this.$container.addClass('display-video');
  516. break;
  517. case DISPLAY_VIDEO_WITH_NAME:
  518. this.$container.addClass('display-name-on-video');
  519. break;
  520. case DISPLAY_AVATAR:
  521. default:
  522. this.$container.addClass('display-avatar-only');
  523. break;
  524. }
  525. };
  526. /**
  527. * Updates the react component displaying the avatar with the passed in avatar
  528. * url.
  529. *
  530. * @param {string} avatarUrl - The uri to the avatar image.
  531. * @returns {void}
  532. */
  533. SmallVideo.prototype.avatarChanged = function(avatarUrl) {
  534. const thumbnail = this.$avatar().get(0);
  535. this.hasAvatar = true;
  536. if (thumbnail) {
  537. ReactDOM.render(
  538. <AvatarDisplay
  539. className = 'userAvatar'
  540. uri = { avatarUrl } />,
  541. thumbnail
  542. );
  543. }
  544. };
  545. /**
  546. * Unmounts any attached react components (particular the avatar image) from
  547. * the avatar container.
  548. *
  549. * @returns {void}
  550. */
  551. SmallVideo.prototype.removeAvatar = function() {
  552. const thumbnail = this.$avatar().get(0);
  553. if (thumbnail) {
  554. ReactDOM.unmountComponentAtNode(thumbnail);
  555. }
  556. };
  557. /**
  558. * Shows or hides the dominant speaker indicator.
  559. * @param show whether to show or hide.
  560. */
  561. SmallVideo.prototype.showDominantSpeakerIndicator = function(show) {
  562. // Don't create and show dominant speaker indicator if
  563. // DISABLE_DOMINANT_SPEAKER_INDICATOR is true
  564. if (interfaceConfig.DISABLE_DOMINANT_SPEAKER_INDICATOR) {
  565. return;
  566. }
  567. if (!this.container) {
  568. logger.warn(`Unable to set dominant speaker indicator - ${
  569. this.videoSpanId} does not exist`);
  570. return;
  571. }
  572. if (this._showDominantSpeaker === show) {
  573. return;
  574. }
  575. this._showDominantSpeaker = show;
  576. this.$container.toggleClass('active-speaker', this._showDominantSpeaker);
  577. this.updateIndicators();
  578. this.updateView();
  579. };
  580. /**
  581. * Shows or hides the raised hand indicator.
  582. * @param show whether to show or hide.
  583. */
  584. SmallVideo.prototype.showRaisedHandIndicator = function(show) {
  585. if (!this.container) {
  586. logger.warn(`Unable to raised hand indication - ${
  587. this.videoSpanId} does not exist`);
  588. return;
  589. }
  590. this._showRaisedHand = show;
  591. this.updateIndicators();
  592. };
  593. /**
  594. * Adds a listener for onresize events for this video, which will monitor for
  595. * resolution changes, will calculate the delay since the moment the listened
  596. * is added, and will fire a RESOLUTION_CHANGED event.
  597. */
  598. SmallVideo.prototype.waitForResolutionChange = function() {
  599. const beforeChange = window.performance.now();
  600. const videos = this.selectVideoElement();
  601. if (!videos || !videos.length || videos.length <= 0) {
  602. return;
  603. }
  604. const video = videos[0];
  605. const oldWidth = video.videoWidth;
  606. const oldHeight = video.videoHeight;
  607. video.onresize = () => {
  608. // eslint-disable-next-line eqeqeq
  609. if (video.videoWidth != oldWidth || video.videoHeight != oldHeight) {
  610. // Only run once.
  611. video.onresize = null;
  612. const delay = window.performance.now() - beforeChange;
  613. const emitter = this.VideoLayout.getEventEmitter();
  614. if (emitter) {
  615. emitter.emit(
  616. UIEvents.RESOLUTION_CHANGED,
  617. this.getId(),
  618. `${oldWidth}x${oldHeight}`,
  619. `${video.videoWidth}x${video.videoHeight}`,
  620. delay);
  621. }
  622. }
  623. };
  624. };
  625. /**
  626. * Initalizes any browser specific properties. Currently sets the overflow
  627. * property for Qt browsers on Windows to hidden, thus fixing the following
  628. * problem:
  629. * Some browsers don't have full support of the object-fit property for the
  630. * video element and when we set video object-fit to "cover" the video
  631. * actually overflows the boundaries of its container, so it's important
  632. * to indicate that the "overflow" should be hidden.
  633. *
  634. * Setting this property for all browsers will result in broken audio levels,
  635. * which makes this a temporary solution, before reworking audio levels.
  636. */
  637. SmallVideo.prototype.initBrowserSpecificProperties = function() {
  638. const userAgent = window.navigator.userAgent;
  639. if (userAgent.indexOf('QtWebEngine') > -1
  640. && (userAgent.indexOf('Windows') > -1
  641. || userAgent.indexOf('Linux') > -1)) {
  642. this.$container.css('overflow', 'hidden');
  643. }
  644. };
  645. /**
  646. * Helper function for re-rendering multiple react components of the small
  647. * video.
  648. *
  649. * @returns {void}
  650. */
  651. SmallVideo.prototype.rerender = function() {
  652. this.updateIndicators();
  653. this.updateStatusBar();
  654. this.updateView();
  655. };
  656. /**
  657. * Updates the React element responsible for showing connection status, dominant
  658. * speaker, and raised hand icons. Uses instance variables to get the necessary
  659. * state to display. Will create the React element if not already created.
  660. *
  661. * @private
  662. * @returns {void}
  663. */
  664. SmallVideo.prototype.updateIndicators = function() {
  665. const indicatorToolbar
  666. = this.container.querySelector('.videocontainer__toptoolbar');
  667. if (!indicatorToolbar) {
  668. return;
  669. }
  670. const iconSize = UIUtil.getIndicatorFontSize();
  671. const showConnectionIndicator = this.videoIsHovered
  672. || !interfaceConfig.CONNECTION_INDICATOR_AUTO_HIDE_ENABLED;
  673. const currentLayout = getCurrentLayout(APP.store.getState());
  674. let statsPopoverPosition, tooltipPosition;
  675. if (currentLayout === LAYOUTS.TILE_VIEW) {
  676. statsPopoverPosition = 'right top';
  677. tooltipPosition = 'right';
  678. } else if (currentLayout === LAYOUTS.VERTICAL_FILMSTRIP_VIEW) {
  679. statsPopoverPosition = this.statsPopoverLocation;
  680. tooltipPosition = 'left';
  681. } else {
  682. statsPopoverPosition = this.statsPopoverLocation;
  683. tooltipPosition = 'top';
  684. }
  685. ReactDOM.render(
  686. <I18nextProvider i18n = { i18next }>
  687. <div>
  688. <AtlasKitThemeProvider mode = 'dark'>
  689. { this._showConnectionIndicator
  690. ? <ConnectionIndicator
  691. alwaysVisible = { showConnectionIndicator }
  692. connectionStatus = { this._connectionStatus }
  693. iconSize = { iconSize }
  694. isLocalVideo = { this.isLocal }
  695. enableStatsDisplay
  696. = { !interfaceConfig.filmStripOnly }
  697. statsPopoverPosition
  698. = { statsPopoverPosition }
  699. userID = { this.id } />
  700. : null }
  701. { this._showRaisedHand
  702. ? <RaisedHandIndicator
  703. iconSize = { iconSize }
  704. tooltipPosition = { tooltipPosition } />
  705. : null }
  706. { this._showDominantSpeaker
  707. ? <DominantSpeakerIndicator
  708. iconSize = { iconSize }
  709. tooltipPosition = { tooltipPosition } />
  710. : null }
  711. </AtlasKitThemeProvider>
  712. </div>
  713. </I18nextProvider>,
  714. indicatorToolbar
  715. );
  716. };
  717. /**
  718. * Pins the participant displayed by this thumbnail or unpins if already pinned.
  719. *
  720. * @private
  721. * @returns {void}
  722. */
  723. SmallVideo.prototype._togglePin = function() {
  724. const pinnedParticipant
  725. = getPinnedParticipant(APP.store.getState()) || {};
  726. const participantIdToPin
  727. = pinnedParticipant && pinnedParticipant.id === this.id
  728. ? null : this.id;
  729. APP.store.dispatch(pinParticipant(participantIdToPin));
  730. };
  731. /**
  732. * Removes the React element responsible for showing connection status, dominant
  733. * speaker, and raised hand icons.
  734. *
  735. * @private
  736. * @returns {void}
  737. */
  738. SmallVideo.prototype._unmountIndicators = function() {
  739. const indicatorToolbar
  740. = this.container.querySelector('.videocontainer__toptoolbar');
  741. if (indicatorToolbar) {
  742. ReactDOM.unmountComponentAtNode(indicatorToolbar);
  743. }
  744. };
  745. /**
  746. * Updates the current state of the connection indicator popover being hovered.
  747. * If hovered, display the small video as if it is hovered.
  748. *
  749. * @param {boolean} popoverIsHovered - Whether or not the mouse cursor is
  750. * currently over the connection indicator popover.
  751. * @returns {void}
  752. */
  753. SmallVideo.prototype._onPopoverHover = function(popoverIsHovered) {
  754. this._popoverIsHovered = popoverIsHovered;
  755. this.updateView();
  756. };
  757. export default SmallVideo;