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

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