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

UI.js 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  1. /* global APP, $, config, interfaceConfig */
  2. const logger = require('jitsi-meet-logger').getLogger(__filename);
  3. const UI = {};
  4. import messageHandler from './util/MessageHandler';
  5. import UIUtil from './util/UIUtil';
  6. import UIEvents from '../../service/UI/UIEvents';
  7. import EtherpadManager from './etherpad/Etherpad';
  8. import SharedVideoManager from './shared_video/SharedVideo';
  9. import VideoLayout from './videolayout/VideoLayout';
  10. import Filmstrip from './videolayout/Filmstrip';
  11. import { getLocalParticipant } from '../../react/features/base/participants';
  12. import { toggleChat } from '../../react/features/chat';
  13. import { openDisplayNamePrompt } from '../../react/features/display-name';
  14. import { setEtherpadHasInitialzied } from '../../react/features/etherpad';
  15. import { setFilmstripVisible } from '../../react/features/filmstrip';
  16. import { setNotificationsEnabled } from '../../react/features/notifications';
  17. import {
  18. dockToolbox,
  19. setToolboxEnabled,
  20. showToolbox
  21. } from '../../react/features/toolbox';
  22. const EventEmitter = require('events');
  23. UI.messageHandler = messageHandler;
  24. const eventEmitter = new EventEmitter();
  25. UI.eventEmitter = eventEmitter;
  26. let etherpadManager;
  27. let sharedVideoManager;
  28. const UIListeners = new Map([
  29. [
  30. UIEvents.ETHERPAD_CLICKED,
  31. () => etherpadManager && etherpadManager.toggleEtherpad()
  32. ], [
  33. UIEvents.SHARED_VIDEO_CLICKED,
  34. () => sharedVideoManager && sharedVideoManager.toggleSharedVideo()
  35. ], [
  36. UIEvents.TOGGLE_FILMSTRIP,
  37. () => UI.toggleFilmstrip()
  38. ]
  39. ]);
  40. /**
  41. * Indicates if we're currently in full screen mode.
  42. *
  43. * @return {boolean} {true} to indicate that we're currently in full screen
  44. * mode, {false} otherwise
  45. */
  46. UI.isFullScreen = function() {
  47. return UIUtil.isFullScreen();
  48. };
  49. /**
  50. * Returns true if the etherpad window is currently visible.
  51. * @returns {Boolean} - true if the etherpad window is currently visible.
  52. */
  53. UI.isEtherpadVisible = function() {
  54. return Boolean(etherpadManager && etherpadManager.isVisible());
  55. };
  56. /**
  57. * Returns true if there is a shared video which is being shown (?).
  58. * @returns {boolean} - true if there is a shared video which is being shown.
  59. */
  60. UI.isSharedVideoShown = function() {
  61. return Boolean(sharedVideoManager && sharedVideoManager.isSharedVideoShown);
  62. };
  63. /**
  64. * Notify user that server has shut down.
  65. */
  66. UI.notifyGracefulShutdown = function() {
  67. messageHandler.showError({
  68. descriptionKey: 'dialog.gracefulShutdown',
  69. titleKey: 'dialog.serviceUnavailable'
  70. });
  71. };
  72. /**
  73. * Notify user that reservation error happened.
  74. */
  75. UI.notifyReservationError = function(code, msg) {
  76. messageHandler.showError({
  77. descriptionArguments: {
  78. code,
  79. msg
  80. },
  81. descriptionKey: 'dialog.reservationErrorMsg',
  82. titleKey: 'dialog.reservationError'
  83. });
  84. };
  85. /**
  86. * Notify user that conference was destroyed.
  87. * @param reason {string} the reason text
  88. */
  89. UI.notifyConferenceDestroyed = function(reason) {
  90. // FIXME: use Session Terminated from translation, but
  91. // 'reason' text comes from XMPP packet and is not translated
  92. messageHandler.showError({
  93. description: reason,
  94. titleKey: 'dialog.sessTerminated'
  95. });
  96. };
  97. /**
  98. * Change nickname for the user.
  99. * @param {string} id user id
  100. * @param {string} displayName new nickname
  101. */
  102. UI.changeDisplayName = function(id, displayName) {
  103. VideoLayout.onDisplayNameChanged(id, displayName);
  104. };
  105. /**
  106. * Initialize conference UI.
  107. */
  108. UI.initConference = function() {
  109. const { getState } = APP.store;
  110. const { id, name } = getLocalParticipant(getState);
  111. // Update default button states before showing the toolbar
  112. // if local role changes buttons state will be again updated.
  113. UI.updateLocalRole(APP.conference.isModerator);
  114. UI.showToolbar();
  115. const displayName = config.displayJids ? id : name;
  116. if (displayName) {
  117. UI.changeDisplayName('localVideoContainer', displayName);
  118. }
  119. };
  120. /**
  121. * Returns the shared document manager object.
  122. * @return {EtherpadManager} the shared document manager object
  123. */
  124. UI.getSharedVideoManager = function() {
  125. return sharedVideoManager;
  126. };
  127. /**
  128. * Starts the UI module and initializes all related components.
  129. *
  130. * @returns {boolean} true if the UI is ready and the conference should be
  131. * established, false - otherwise (for example in the case of welcome page)
  132. */
  133. UI.start = function() {
  134. document.title = interfaceConfig.APP_NAME;
  135. // Set the defaults for prompt dialogs.
  136. $.prompt.setDefaults({ persistent: false });
  137. Filmstrip.init(eventEmitter);
  138. VideoLayout.init(eventEmitter);
  139. if (!interfaceConfig.filmStripOnly) {
  140. VideoLayout.initLargeVideo();
  141. }
  142. // Do not animate the video area on UI start (second argument passed into
  143. // resizeVideoArea) because the animation is not visible anyway. Plus with
  144. // the current dom layout, the quality label is part of the video layout and
  145. // will be seen animating in.
  146. VideoLayout.resizeVideoArea(true, false);
  147. sharedVideoManager = new SharedVideoManager(eventEmitter);
  148. if (interfaceConfig.filmStripOnly) {
  149. $('body').addClass('filmstrip-only');
  150. APP.store.dispatch(setNotificationsEnabled(false));
  151. } else if (config.iAmRecorder) {
  152. // in case of iAmSipGateway keep local video visible
  153. if (!config.iAmSipGateway) {
  154. VideoLayout.setLocalVideoVisible(false);
  155. }
  156. APP.store.dispatch(setToolboxEnabled(false));
  157. APP.store.dispatch(setNotificationsEnabled(false));
  158. UI.messageHandler.enablePopups(false);
  159. }
  160. document.title = interfaceConfig.APP_NAME;
  161. };
  162. /**
  163. * Setup some UI event listeners.
  164. */
  165. UI.registerListeners
  166. = () => UIListeners.forEach((value, key) => UI.addListener(key, value));
  167. /**
  168. * Setup some DOM event listeners.
  169. */
  170. UI.bindEvents = () => {
  171. /**
  172. *
  173. */
  174. function onResize() {
  175. VideoLayout.resizeVideoArea();
  176. }
  177. // Resize and reposition videos in full screen mode.
  178. $(document).on(
  179. 'webkitfullscreenchange mozfullscreenchange fullscreenchange',
  180. onResize);
  181. $(window).resize(onResize);
  182. };
  183. /**
  184. * Unbind some DOM event listeners.
  185. */
  186. UI.unbindEvents = () => {
  187. $(document).off(
  188. 'webkitfullscreenchange mozfullscreenchange fullscreenchange');
  189. $(window).off('resize');
  190. };
  191. /**
  192. * Show local video stream on UI.
  193. * @param {JitsiTrack} track stream to show
  194. */
  195. UI.addLocalVideoStream = track => {
  196. VideoLayout.changeLocalVideo(track);
  197. };
  198. /**
  199. * Setup and show Etherpad.
  200. * @param {string} name etherpad id
  201. */
  202. UI.initEtherpad = name => {
  203. if (etherpadManager || !config.etherpad_base || !name) {
  204. return;
  205. }
  206. logger.log('Etherpad is enabled');
  207. etherpadManager
  208. = new EtherpadManager(config.etherpad_base, name, eventEmitter);
  209. APP.store.dispatch(setEtherpadHasInitialzied());
  210. };
  211. /**
  212. * Returns the shared document manager object.
  213. * @return {EtherpadManager} the shared document manager object
  214. */
  215. UI.getSharedDocumentManager = () => etherpadManager;
  216. /**
  217. * Show user on UI.
  218. * @param {JitsiParticipant} user
  219. */
  220. UI.addUser = function(user) {
  221. const id = user.getId();
  222. const displayName = user.getDisplayName();
  223. const status = user.getStatus();
  224. if (status) {
  225. // FIXME: move updateUserStatus in participantPresenceChanged action
  226. UI.updateUserStatus(user, status);
  227. }
  228. // set initial display name
  229. if (displayName) {
  230. UI.changeDisplayName(id, displayName);
  231. }
  232. };
  233. /**
  234. * Update videotype for specified user.
  235. * @param {string} id user id
  236. * @param {string} newVideoType new videotype
  237. */
  238. UI.onPeerVideoTypeChanged
  239. = (id, newVideoType) => VideoLayout.onVideoTypeChanged(id, newVideoType);
  240. /**
  241. * Update local user role and show notification if user is moderator.
  242. * @param {boolean} isModerator if local user is moderator or not
  243. */
  244. UI.updateLocalRole = isModerator => {
  245. VideoLayout.showModeratorIndicator();
  246. if (isModerator && !interfaceConfig.DISABLE_FOCUS_INDICATOR) {
  247. messageHandler.participantNotification(
  248. null, 'notify.me', 'connected', 'notify.moderator');
  249. }
  250. };
  251. /**
  252. * Check the role for the user and reflect it in the UI, moderator ui indication
  253. * and notifies user who is the moderator
  254. * @param user to check for moderator
  255. */
  256. UI.updateUserRole = user => {
  257. VideoLayout.showModeratorIndicator();
  258. // We don't need to show moderator notifications when the focus (moderator)
  259. // indicator is disabled.
  260. if (!user.isModerator() || interfaceConfig.DISABLE_FOCUS_INDICATOR) {
  261. return;
  262. }
  263. const displayName = user.getDisplayName();
  264. messageHandler.participantNotification(
  265. displayName,
  266. 'notify.somebody',
  267. 'connected',
  268. 'notify.grantedTo',
  269. { to: displayName
  270. ? UIUtil.escapeHtml(displayName) : '$t(notify.somebody)' });
  271. };
  272. /**
  273. * Updates the user status.
  274. *
  275. * @param {JitsiParticipant} user - The user which status we need to update.
  276. * @param {string} status - The new status.
  277. */
  278. UI.updateUserStatus = (user, status) => {
  279. const reduxState = APP.store.getState() || {};
  280. const { calleeInfoVisible } = reduxState['features/invite'] || {};
  281. if (!status || calleeInfoVisible) {
  282. return;
  283. }
  284. const displayName = user.getDisplayName();
  285. messageHandler.participantNotification(
  286. displayName,
  287. '',
  288. 'connected',
  289. 'dialOut.statusMessage',
  290. { status: UIUtil.escapeHtml(status) });
  291. };
  292. /**
  293. * Toggles filmstrip.
  294. */
  295. UI.toggleFilmstrip = function() {
  296. const { visible } = APP.store.getState()['features/filmstrip'];
  297. APP.store.dispatch(setFilmstripVisible(!visible));
  298. };
  299. /**
  300. * Checks if the filmstrip is currently visible or not.
  301. * @returns {true} if the filmstrip is currently visible, and false otherwise.
  302. */
  303. UI.isFilmstripVisible = () => Filmstrip.isFilmstripVisible();
  304. /**
  305. * Toggles the visibility of the chat panel.
  306. */
  307. UI.toggleChat = () => APP.store.dispatch(toggleChat());
  308. /**
  309. * Handle new user display name.
  310. */
  311. UI.inputDisplayNameHandler = function(newDisplayName) {
  312. eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newDisplayName);
  313. };
  314. /**
  315. * Return the type of the remote video.
  316. * @param jid the jid for the remote video
  317. * @returns the video type video or screen.
  318. */
  319. UI.getRemoteVideoType = function(jid) {
  320. return VideoLayout.getRemoteVideoType(jid);
  321. };
  322. // FIXME check if someone user this
  323. UI.showLoginPopup = function(callback) {
  324. logger.log('password is required');
  325. const message
  326. = `<input name="username" type="text"
  327. placeholder="user@domain.net"
  328. class="input-control" autofocus>
  329. <input name="password" type="password"
  330. data-i18n="[placeholder]dialog.userPassword"
  331. class="input-control"
  332. placeholder="user password">`
  333. ;
  334. // eslint-disable-next-line max-params
  335. const submitFunction = (e, v, m, f) => {
  336. if (v && f.username && f.password) {
  337. callback(f.username, f.password);
  338. }
  339. };
  340. messageHandler.openTwoButtonDialog({
  341. titleKey: 'dialog.passwordRequired',
  342. msgString: message,
  343. leftButtonKey: 'dialog.Ok',
  344. submitFunction,
  345. focus: ':input:first'
  346. });
  347. };
  348. UI.askForNickname = function() {
  349. // eslint-disable-next-line no-alert
  350. return window.prompt('Your nickname (optional)');
  351. };
  352. /**
  353. * Sets muted audio state for participant
  354. */
  355. UI.setAudioMuted = function(id, muted) {
  356. VideoLayout.onAudioMute(id, muted);
  357. if (APP.conference.isLocalId(id)) {
  358. APP.conference.updateAudioIconEnabled();
  359. }
  360. };
  361. /**
  362. * Sets muted video state for participant
  363. */
  364. UI.setVideoMuted = function(id, muted) {
  365. VideoLayout.onVideoMute(id, muted);
  366. if (APP.conference.isLocalId(id)) {
  367. APP.conference.updateVideoIconEnabled();
  368. }
  369. };
  370. /**
  371. * Triggers an update of remote video and large video displays so they may pick
  372. * up any state changes that have occurred elsewhere.
  373. *
  374. * @returns {void}
  375. */
  376. UI.updateAllVideos = () => VideoLayout.updateAllVideos();
  377. /**
  378. * Adds a listener that would be notified on the given type of event.
  379. *
  380. * @param type the type of the event we're listening for
  381. * @param listener a function that would be called when notified
  382. */
  383. UI.addListener = function(type, listener) {
  384. eventEmitter.on(type, listener);
  385. };
  386. /**
  387. * Removes the all listeners for all events.
  388. *
  389. * @returns {void}
  390. */
  391. UI.removeAllListeners = function() {
  392. eventEmitter.removeAllListeners();
  393. };
  394. /**
  395. * Removes the given listener for the given type of event.
  396. *
  397. * @param type the type of the event we're listening for
  398. * @param listener the listener we want to remove
  399. */
  400. UI.removeListener = function(type, listener) {
  401. eventEmitter.removeListener(type, listener);
  402. };
  403. /**
  404. * Emits the event of given type by specifying the parameters in options.
  405. *
  406. * @param type the type of the event we're emitting
  407. * @param options the parameters for the event
  408. */
  409. UI.emitEvent = (type, ...options) => eventEmitter.emit(type, ...options);
  410. UI.clickOnVideo = videoNumber => VideoLayout.togglePin(videoNumber);
  411. // Used by torture.
  412. UI.showToolbar = timeout => APP.store.dispatch(showToolbox(timeout));
  413. // Used by torture.
  414. UI.dockToolbar = dock => APP.store.dispatch(dockToolbox(dock));
  415. /**
  416. * Updates the displayed avatar for participant.
  417. *
  418. * @param {string} id - User id whose avatar should be updated.
  419. * @param {string} avatarURL - The URL to avatar image to display.
  420. * @returns {void}
  421. */
  422. UI.refreshAvatarDisplay = function(id) {
  423. VideoLayout.changeUserAvatar(id);
  424. };
  425. /**
  426. * Notify user that connection failed.
  427. * @param {string} stropheErrorMsg raw Strophe error message
  428. */
  429. UI.notifyConnectionFailed = function(stropheErrorMsg) {
  430. let descriptionKey;
  431. let descriptionArguments;
  432. if (stropheErrorMsg) {
  433. descriptionKey = 'dialog.connectErrorWithMsg';
  434. descriptionArguments = { msg: stropheErrorMsg };
  435. } else {
  436. descriptionKey = 'dialog.connectError';
  437. }
  438. messageHandler.showError({
  439. descriptionArguments,
  440. descriptionKey,
  441. titleKey: 'connection.CONNFAIL'
  442. });
  443. };
  444. /**
  445. * Notify user that maximum users limit has been reached.
  446. */
  447. UI.notifyMaxUsersLimitReached = function() {
  448. messageHandler.showError({
  449. hideErrorSupportLink: true,
  450. descriptionKey: 'dialog.maxUsersLimitReached',
  451. titleKey: 'dialog.maxUsersLimitReachedTitle'
  452. });
  453. };
  454. /**
  455. * Notify user that he was automatically muted when joned the conference.
  456. */
  457. UI.notifyInitiallyMuted = function() {
  458. messageHandler.participantNotification(
  459. null,
  460. 'notify.mutedTitle',
  461. 'connected',
  462. 'notify.muted',
  463. null);
  464. };
  465. UI.handleLastNEndpoints = function(leavingIds, enteringIds) {
  466. VideoLayout.onLastNEndpointsChanged(leavingIds, enteringIds);
  467. };
  468. /**
  469. * Prompt user for nickname.
  470. */
  471. UI.promptDisplayName = () => {
  472. APP.store.dispatch(openDisplayNamePrompt(undefined));
  473. };
  474. /**
  475. * Update audio level visualization for specified user.
  476. * @param {string} id user id
  477. * @param {number} lvl audio level
  478. */
  479. UI.setAudioLevel = (id, lvl) => VideoLayout.setAudioLevel(id, lvl);
  480. /**
  481. * Hide connection quality statistics from UI.
  482. */
  483. UI.hideStats = function() {
  484. VideoLayout.hideStats();
  485. };
  486. UI.notifyTokenAuthFailed = function() {
  487. messageHandler.showError({
  488. descriptionKey: 'dialog.tokenAuthFailed',
  489. titleKey: 'dialog.tokenAuthFailedTitle'
  490. });
  491. };
  492. UI.notifyInternalError = function(error) {
  493. messageHandler.showError({
  494. descriptionArguments: { error },
  495. descriptionKey: 'dialog.internalError',
  496. titleKey: 'dialog.internalErrorTitle'
  497. });
  498. };
  499. UI.notifyFocusDisconnected = function(focus, retrySec) {
  500. messageHandler.participantNotification(
  501. null, 'notify.focus',
  502. 'disconnected', 'notify.focusFail',
  503. { component: focus,
  504. ms: retrySec }
  505. );
  506. };
  507. /**
  508. * Notifies interested listeners that the raise hand property has changed.
  509. *
  510. * @param {boolean} isRaisedHand indicates the current state of the
  511. * "raised hand"
  512. */
  513. UI.onLocalRaiseHandChanged = function(isRaisedHand) {
  514. eventEmitter.emit(UIEvents.LOCAL_RAISE_HAND_CHANGED, isRaisedHand);
  515. };
  516. /**
  517. * Update list of available physical devices.
  518. */
  519. UI.onAvailableDevicesChanged = function() {
  520. APP.conference.updateAudioIconEnabled();
  521. APP.conference.updateVideoIconEnabled();
  522. };
  523. /**
  524. * Returns the id of the current video shown on large.
  525. * Currently used by tests (torture).
  526. */
  527. UI.getLargeVideoID = function() {
  528. return VideoLayout.getLargeVideoID();
  529. };
  530. /**
  531. * Returns the current video shown on large.
  532. * Currently used by tests (torture).
  533. */
  534. UI.getLargeVideo = function() {
  535. return VideoLayout.getLargeVideo();
  536. };
  537. /**
  538. * Shows "Please go to chrome webstore to install the desktop sharing extension"
  539. * 2 button dialog with buttons - cancel and go to web store.
  540. * @param url {string} the url of the extension.
  541. */
  542. UI.showExtensionExternalInstallationDialog = function(url) {
  543. let openedWindow = null;
  544. const submitFunction = function(e, v) {
  545. if (v) {
  546. e.preventDefault();
  547. if (openedWindow === null || openedWindow.closed) {
  548. openedWindow
  549. = window.open(
  550. url,
  551. 'extension_store_window',
  552. 'resizable,scrollbars=yes,status=1');
  553. } else {
  554. openedWindow.focus();
  555. }
  556. }
  557. };
  558. const closeFunction = function(e, v) {
  559. if (openedWindow) {
  560. // Ideally we would close the popup, but this does not seem to work
  561. // on Chrome. Leaving it uncommented in case it could work
  562. // in some version.
  563. openedWindow.close();
  564. openedWindow = null;
  565. }
  566. if (!v) {
  567. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  568. }
  569. };
  570. messageHandler.openTwoButtonDialog({
  571. titleKey: 'dialog.externalInstallationTitle',
  572. msgKey: 'dialog.externalInstallationMsg',
  573. leftButtonKey: 'dialog.goToStore',
  574. submitFunction,
  575. loadedFunction: $.noop,
  576. closeFunction
  577. });
  578. };
  579. /**
  580. * Shows a dialog which asks user to install the extension. This one is
  581. * displayed after installation is triggered from the script, but fails because
  582. * it must be initiated by user gesture.
  583. * @param callback {function} function to be executed after user clicks
  584. * the install button - it should make another attempt to install the extension.
  585. */
  586. UI.showExtensionInlineInstallationDialog = function(callback) {
  587. const submitFunction = function(e, v) {
  588. if (v) {
  589. callback();
  590. }
  591. };
  592. const closeFunction = function(e, v) {
  593. if (!v) {
  594. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  595. }
  596. };
  597. messageHandler.openTwoButtonDialog({
  598. titleKey: 'dialog.externalInstallationTitle',
  599. msgKey: 'dialog.inlineInstallationMsg',
  600. leftButtonKey: 'dialog.inlineInstallExtension',
  601. submitFunction,
  602. loadedFunction: $.noop,
  603. closeFunction
  604. });
  605. };
  606. UI.updateDevicesAvailability = function(id, devices) {
  607. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  608. };
  609. /**
  610. * Show shared video.
  611. * @param {string} id the id of the sender of the command
  612. * @param {string} url video url
  613. * @param {string} attributes
  614. */
  615. UI.onSharedVideoStart = function(id, url, attributes) {
  616. if (sharedVideoManager) {
  617. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  618. }
  619. };
  620. /**
  621. * Update shared video.
  622. * @param {string} id the id of the sender of the command
  623. * @param {string} url video url
  624. * @param {string} attributes
  625. */
  626. UI.onSharedVideoUpdate = function(id, url, attributes) {
  627. if (sharedVideoManager) {
  628. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  629. }
  630. };
  631. /**
  632. * Stop showing shared video.
  633. * @param {string} id the id of the sender of the command
  634. * @param {string} attributes
  635. */
  636. UI.onSharedVideoStop = function(id, attributes) {
  637. if (sharedVideoManager) {
  638. sharedVideoManager.onSharedVideoStop(id, attributes);
  639. }
  640. };
  641. /**
  642. * Handles user's features changes.
  643. */
  644. UI.onUserFeaturesChanged = user => VideoLayout.onUserFeaturesChanged(user);
  645. /**
  646. * Returns the number of known remote videos.
  647. *
  648. * @returns {number} The number of remote videos.
  649. */
  650. UI.getRemoteVideosCount = () => VideoLayout.getRemoteVideosCount();
  651. /**
  652. * Sets the remote control active status for a remote participant.
  653. *
  654. * @param {string} participantID - The id of the remote participant.
  655. * @param {boolean} isActive - The new remote control active status.
  656. * @returns {void}
  657. */
  658. UI.setRemoteControlActiveStatus = function(participantID, isActive) {
  659. VideoLayout.setRemoteControlActiveStatus(participantID, isActive);
  660. };
  661. /**
  662. * Sets the remote control active status for the local participant.
  663. *
  664. * @returns {void}
  665. */
  666. UI.setLocalRemoteControlActiveChanged = function() {
  667. VideoLayout.setLocalRemoteControlActiveChanged();
  668. };
  669. // TODO: Export every function separately. For now there is no point of doing
  670. // this because we are importing everything.
  671. export default UI;