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.

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