Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

UI.js 21KB

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