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 40KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446
  1. /* global APP, JitsiMeetJS, $, config, interfaceConfig, toastr */
  2. var UI = {};
  3. import Chat from "./side_pannels/chat/Chat";
  4. import SidePanels from "./side_pannels/SidePanels";
  5. import Toolbar from "./toolbars/Toolbar";
  6. import ToolbarToggler from "./toolbars/ToolbarToggler";
  7. import Avatar from "./avatar/Avatar";
  8. import SideContainerToggler from "./side_pannels/SideContainerToggler";
  9. import UIUtil from "./util/UIUtil";
  10. import UIEvents from "../../service/UI/UIEvents";
  11. import EtherpadManager from './etherpad/Etherpad';
  12. import SharedVideoManager from './shared_video/SharedVideo';
  13. import Recording from "./recording/Recording";
  14. import GumPermissionsOverlay
  15. from './gum_overlay/UserMediaPermissionsGuidanceOverlay';
  16. import PageReloadOverlay from './reload_overlay/PageReloadOverlay';
  17. import VideoLayout from "./videolayout/VideoLayout";
  18. import FilmStrip from "./videolayout/FilmStrip";
  19. import SettingsMenu from "./side_pannels/settings/SettingsMenu";
  20. import Profile from "./side_pannels/profile/Profile";
  21. import Settings from "./../settings/Settings";
  22. import RingOverlay from "./ring_overlay/RingOverlay";
  23. import RandomUtil from "../util/RandomUtil";
  24. import UIErrors from './UIErrors';
  25. import { debounce } from "../util/helpers";
  26. var EventEmitter = require("events");
  27. UI.messageHandler = require("./util/MessageHandler");
  28. var messageHandler = UI.messageHandler;
  29. var JitsiPopover = require("./util/JitsiPopover");
  30. var Feedback = require("./feedback/Feedback");
  31. import FollowMe from "../FollowMe";
  32. var eventEmitter = new EventEmitter();
  33. UI.eventEmitter = eventEmitter;
  34. let etherpadManager;
  35. let sharedVideoManager;
  36. let followMeHandler;
  37. let deviceErrorDialog;
  38. const TrackErrors = JitsiMeetJS.errors.track;
  39. const JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP = {
  40. microphone: {},
  41. camera: {}
  42. };
  43. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.UNSUPPORTED_RESOLUTION]
  44. = "dialog.cameraUnsupportedResolutionError";
  45. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  46. = "dialog.cameraUnknownError";
  47. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.PERMISSION_DENIED]
  48. = "dialog.cameraPermissionDeniedError";
  49. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NOT_FOUND]
  50. = "dialog.cameraNotFoundError";
  51. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.CONSTRAINT_FAILED]
  52. = "dialog.cameraConstraintFailedError";
  53. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.NO_DATA_FROM_SOURCE]
  54. = "dialog.cameraNotSendingData";
  55. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  56. = "dialog.micUnknownError";
  57. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.PERMISSION_DENIED]
  58. = "dialog.micPermissionDeniedError";
  59. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NOT_FOUND]
  60. = "dialog.micNotFoundError";
  61. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.CONSTRAINT_FAILED]
  62. = "dialog.micConstraintFailedError";
  63. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.NO_DATA_FROM_SOURCE]
  64. = "dialog.micNotSendingData";
  65. /**
  66. * Prompt user for nickname.
  67. */
  68. function promptDisplayName() {
  69. let labelKey = 'dialog.enterDisplayName';
  70. let message = (
  71. `<div class="input-control">
  72. <label data-i18n="${labelKey}" class="input-control__label"></label>
  73. <input name="displayName" type="text"
  74. data-i18n="[placeholder]defaultNickname"
  75. class="input-control__input"
  76. autofocus>
  77. </div>`
  78. );
  79. // Don't use a translation string, because we're too early in the call and
  80. // the translation may not be initialised.
  81. let buttons = {Ok:true};
  82. let dialog = messageHandler.openDialog(
  83. 'dialog.displayNameRequired',
  84. message,
  85. true,
  86. buttons,
  87. function (e, v, m, f) {
  88. e.preventDefault();
  89. if (v) {
  90. let displayName = f.displayName;
  91. if (displayName) {
  92. UI.inputDisplayNameHandler(displayName);
  93. dialog.close();
  94. return;
  95. }
  96. }
  97. },
  98. function () {
  99. let form = $.prompt.getPrompt();
  100. let input = form.find("input[name='displayName']");
  101. input.focus();
  102. let button = form.find("button");
  103. button.attr("disabled", "disabled");
  104. input.keyup(function () {
  105. if (input.val()) {
  106. button.removeAttr("disabled");
  107. } else {
  108. button.attr("disabled", "disabled");
  109. }
  110. });
  111. }
  112. );
  113. }
  114. /**
  115. * Initialize toolbars with side panels.
  116. */
  117. function setupToolbars() {
  118. // Initialize toolbar buttons
  119. Toolbar.init(eventEmitter);
  120. // Initialize side panels
  121. SidePanels.init(eventEmitter);
  122. }
  123. /**
  124. * Toggles the application in and out of full screen mode
  125. * (a.k.a. presentation mode in Chrome).
  126. */
  127. UI.toggleFullScreen = function() {
  128. (UIUtil.isFullScreen())
  129. ? UIUtil.exitFullScreen()
  130. : UIUtil.enterFullScreen();
  131. };
  132. /**
  133. * Notify user that server has shut down.
  134. */
  135. UI.notifyGracefulShutdown = function () {
  136. messageHandler.openMessageDialog(
  137. 'dialog.serviceUnavailable',
  138. 'dialog.gracefulShutdown'
  139. );
  140. };
  141. /**
  142. * Notify user that reservation error happened.
  143. */
  144. UI.notifyReservationError = function (code, msg) {
  145. var message = APP.translation.generateTranslationHTML(
  146. "dialog.reservationErrorMsg", {code: code, msg: msg});
  147. messageHandler.openDialog(
  148. "dialog.reservationError", message, true, {}, () => false);
  149. };
  150. /**
  151. * Notify user that he has been kicked from the server.
  152. */
  153. UI.notifyKicked = function () {
  154. messageHandler.openMessageDialog(
  155. "dialog.sessTerminated",
  156. "dialog.kickMessage");
  157. };
  158. /**
  159. * Notify user that conference was destroyed.
  160. * @param reason {string} the reason text
  161. */
  162. UI.notifyConferenceDestroyed = function (reason) {
  163. //FIXME: use Session Terminated from translation, but
  164. // 'reason' text comes from XMPP packet and is not translated
  165. messageHandler.openDialog(
  166. "dialog.sessTerminated", reason, true, {}, () => false);
  167. };
  168. /**
  169. * Show chat error.
  170. * @param err the Error
  171. * @param msg
  172. */
  173. UI.showChatError = function (err, msg) {
  174. if (interfaceConfig.filmStripOnly) {
  175. return;
  176. }
  177. Chat.chatAddError(err, msg);
  178. };
  179. /**
  180. * Change nickname for the user.
  181. * @param {string} id user id
  182. * @param {string} displayName new nickname
  183. */
  184. UI.changeDisplayName = function (id, displayName) {
  185. if (UI.ContactList)
  186. UI.ContactList.onDisplayNameChange(id, displayName);
  187. VideoLayout.onDisplayNameChanged(id, displayName);
  188. if (APP.conference.isLocalId(id) || id === 'localVideoContainer') {
  189. Profile.changeDisplayName(displayName);
  190. Chat.setChatConversationMode(!!displayName);
  191. }
  192. };
  193. /**
  194. * Shows/hides the indication about local connection being interrupted.
  195. *
  196. * @param {boolean} isInterrupted <tt>true</tt> if local connection is
  197. * currently in the interrupted state or <tt>false</tt> if the connection
  198. * is fine.
  199. */
  200. UI.showLocalConnectionInterrupted = function (isInterrupted) {
  201. VideoLayout.showLocalConnectionInterrupted(isInterrupted);
  202. };
  203. /**
  204. * Sets the "raised hand" status for a participant.
  205. */
  206. UI.setRaisedHandStatus = (participant, raisedHandStatus) => {
  207. VideoLayout.setRaisedHandStatus(participant.getId(), raisedHandStatus);
  208. if (raisedHandStatus) {
  209. messageHandler.notify(participant.getDisplayName(), 'notify.somebody',
  210. 'connected', 'notify.raisedHand');
  211. }
  212. };
  213. /**
  214. * Sets the local "raised hand" status.
  215. */
  216. UI.setLocalRaisedHandStatus = (raisedHandStatus) => {
  217. VideoLayout.setRaisedHandStatus(
  218. APP.conference.getMyUserId(),
  219. raisedHandStatus);
  220. };
  221. /**
  222. * Initialize conference UI.
  223. */
  224. UI.initConference = function () {
  225. let id = APP.conference.getMyUserId();
  226. // Add myself to the contact list.
  227. if (UI.ContactList)
  228. UI.ContactList.addContact(id, true);
  229. // Update default button states before showing the toolbar
  230. // if local role changes buttons state will be again updated.
  231. UI.updateLocalRole(APP.conference.isModerator);
  232. UI.showToolbar();
  233. let displayName = config.displayJids ? id : Settings.getDisplayName();
  234. if (displayName) {
  235. UI.changeDisplayName('localVideoContainer', displayName);
  236. }
  237. // Make sure we configure our avatar id, before creating avatar for us
  238. let email = Settings.getEmail();
  239. if (email) {
  240. UI.setUserEmail(id, email);
  241. } else {
  242. UI.setUserAvatarID(id, Settings.getAvatarId());
  243. }
  244. Toolbar.checkAutoEnableDesktopSharing();
  245. if(!interfaceConfig.filmStripOnly) {
  246. Feedback.init(eventEmitter);
  247. }
  248. // FollowMe attempts to copy certain aspects of the moderator's UI into the
  249. // other participants' UI. Consequently, it needs (1) read and write access
  250. // to the UI (depending on the moderator role of the local participant) and
  251. // (2) APP.conference as means of communication between the participants.
  252. followMeHandler = new FollowMe(APP.conference, UI);
  253. UIUtil.activateTooltips();
  254. };
  255. UI.mucJoined = function () {
  256. VideoLayout.mucJoined();
  257. };
  258. /***
  259. * Handler for toggling filmstrip
  260. */
  261. UI.handleToggleFilmStrip = () => {
  262. UI.toggleFilmStrip();
  263. };
  264. /**
  265. * Sets tooltip defaults.
  266. *
  267. * @private
  268. */
  269. function _setTooltipDefaults() {
  270. $.fn.tooltip.defaults = {
  271. opacity: 1, //defaults to 1
  272. offset: 1,
  273. delayIn: 0, //defaults to 500
  274. hoverable: true,
  275. hideOnClick: true,
  276. aria: true
  277. };
  278. }
  279. /**
  280. * Setup some UI event listeners.
  281. */
  282. function registerListeners() {
  283. UI.addListener(UIEvents.ETHERPAD_CLICKED, function () {
  284. if (etherpadManager) {
  285. etherpadManager.toggleEtherpad();
  286. }
  287. });
  288. UI.addListener(UIEvents.SHARED_VIDEO_CLICKED, function () {
  289. if (sharedVideoManager) {
  290. sharedVideoManager.toggleSharedVideo();
  291. }
  292. });
  293. UI.addListener(UIEvents.TOGGLE_FULLSCREEN, UI.toggleFullScreen);
  294. UI.addListener(UIEvents.TOGGLE_CHAT, UI.toggleChat);
  295. UI.addListener(UIEvents.TOGGLE_SETTINGS, function () {
  296. UI.toggleSidePanel("settings_container");
  297. });
  298. UI.addListener(UIEvents.TOGGLE_CONTACT_LIST, UI.toggleContactList);
  299. UI.addListener( UIEvents.TOGGLE_PROFILE, function() {
  300. if(APP.tokenData.isGuest)
  301. UI.toggleSidePanel("profile_container");
  302. });
  303. UI.addListener(UIEvents.TOGGLE_FILM_STRIP, UI.handleToggleFilmStrip);
  304. UI.addListener(UIEvents.FOLLOW_ME_ENABLED, function (isEnabled) {
  305. if (followMeHandler)
  306. followMeHandler.enableFollowMe(isEnabled);
  307. });
  308. }
  309. /**
  310. * Setup some DOM event listeners.
  311. */
  312. function bindEvents() {
  313. function onResize() {
  314. SideContainerToggler.resize();
  315. VideoLayout.resizeVideoArea();
  316. }
  317. // Resize and reposition videos in full screen mode.
  318. $(document).on(
  319. 'webkitfullscreenchange mozfullscreenchange fullscreenchange',
  320. () => {
  321. eventEmitter.emit( UIEvents.FULLSCREEN_TOGGLED,
  322. UIUtil.isFullScreen());
  323. onResize();
  324. }
  325. );
  326. $(window).resize(onResize);
  327. }
  328. /**
  329. * Returns the shared document manager object.
  330. * @return {EtherpadManager} the shared document manager object
  331. */
  332. UI.getSharedVideoManager = function () {
  333. return sharedVideoManager;
  334. };
  335. /**
  336. * Starts the UI module and initializes all related components.
  337. *
  338. * @returns {boolean} true if the UI is ready and the conference should be
  339. * esablished, false - otherwise (for example in the case of welcome page)
  340. */
  341. UI.start = function () {
  342. document.title = interfaceConfig.APP_NAME;
  343. var setupWelcomePage = null;
  344. if(config.enableWelcomePage && window.location.pathname == "/" &&
  345. Settings.isWelcomePageEnabled()) {
  346. $("#videoconference_page").hide();
  347. if (!setupWelcomePage)
  348. setupWelcomePage = require("./welcome_page/WelcomePage");
  349. setupWelcomePage();
  350. // Return false to indicate that the UI hasn't been fully started and
  351. // conference ready. We're still waiting for input from the user.
  352. return false;
  353. }
  354. $("#welcome_page").hide();
  355. // Set the defaults for prompt dialogs.
  356. $.prompt.setDefaults({persistent: false});
  357. // Set the defaults for tooltips.
  358. _setTooltipDefaults();
  359. registerListeners();
  360. ToolbarToggler.init();
  361. SideContainerToggler.init(eventEmitter);
  362. FilmStrip.init(eventEmitter);
  363. VideoLayout.init(eventEmitter);
  364. if (!interfaceConfig.filmStripOnly) {
  365. VideoLayout.initLargeVideo();
  366. }
  367. VideoLayout.resizeVideoArea(true, true);
  368. bindEvents();
  369. sharedVideoManager = new SharedVideoManager(eventEmitter);
  370. if (!interfaceConfig.filmStripOnly) {
  371. let debouncedShowToolbar = debounce(() => {
  372. UI.showToolbar();
  373. }, 100, { leading: true, trailing: false });
  374. $("#videoconference_page").mousemove(debouncedShowToolbar);
  375. setupToolbars();
  376. // Initialise the recording module.
  377. if (config.enableRecording)
  378. Recording.init(eventEmitter, config.recordingType);
  379. // Display notice message at the top of the toolbar
  380. if (config.noticeMessage) {
  381. $('#noticeText').text(config.noticeMessage);
  382. $('#notice').css({display: 'block'});
  383. }
  384. } else {
  385. $("#mainToolbarContainer").css("display", "none");
  386. FilmStrip.setupFilmStripOnly();
  387. messageHandler.enableNotifications(false);
  388. JitsiPopover.enabled = false;
  389. }
  390. document.title = interfaceConfig.APP_NAME;
  391. if(config.requireDisplayName) {
  392. if (!APP.settings.getDisplayName()) {
  393. promptDisplayName();
  394. }
  395. }
  396. if (!interfaceConfig.filmStripOnly) {
  397. toastr.options = {
  398. "closeButton": true,
  399. "debug": false,
  400. "positionClass": "notification-bottom-right",
  401. "onclick": null,
  402. "showDuration": "300",
  403. "hideDuration": "1000",
  404. "timeOut": "2000",
  405. "extendedTimeOut": "1000",
  406. "showEasing": "swing",
  407. "hideEasing": "linear",
  408. "showMethod": "fadeIn",
  409. "hideMethod": "fadeOut",
  410. "newestOnTop": false
  411. };
  412. }
  413. if(APP.tokenData.callee) {
  414. UI.showRingOverlay();
  415. }
  416. // Return true to indicate that the UI has been fully started and
  417. // conference ready.
  418. return true;
  419. };
  420. /**
  421. * Show local stream on UI.
  422. * @param {JitsiTrack} track stream to show
  423. */
  424. UI.addLocalStream = function (track) {
  425. switch (track.getType()) {
  426. case 'audio':
  427. VideoLayout.changeLocalAudio(track);
  428. break;
  429. case 'video':
  430. VideoLayout.changeLocalVideo(track);
  431. break;
  432. default:
  433. console.error("Unknown stream type: " + track.getType());
  434. break;
  435. }
  436. };
  437. /**
  438. * Show remote stream on UI.
  439. * @param {JitsiTrack} track stream to show
  440. */
  441. UI.addRemoteStream = function (track) {
  442. VideoLayout.onRemoteStreamAdded(track);
  443. };
  444. /**
  445. * Removed remote stream from UI.
  446. * @param {JitsiTrack} track stream to remove
  447. */
  448. UI.removeRemoteStream = function (track) {
  449. VideoLayout.onRemoteStreamRemoved(track);
  450. };
  451. /**
  452. * Update chat subject.
  453. * @param {string} subject new chat subject
  454. */
  455. UI.setSubject = function (subject) {
  456. Chat.setSubject(subject);
  457. };
  458. /**
  459. * Setup and show Etherpad.
  460. * @param {string} name etherpad id
  461. */
  462. UI.initEtherpad = function (name) {
  463. if (etherpadManager || !config.etherpad_base || !name) {
  464. return;
  465. }
  466. console.log('Etherpad is enabled');
  467. etherpadManager
  468. = new EtherpadManager(config.etherpad_base, name, eventEmitter);
  469. Toolbar.showEtherpadButton();
  470. };
  471. /**
  472. * Returns the shared document manager object.
  473. * @return {EtherpadManager} the shared document manager object
  474. */
  475. UI.getSharedDocumentManager = function () {
  476. return etherpadManager;
  477. };
  478. /**
  479. * Show user on UI.
  480. * @param {JitsiParticipant} user
  481. */
  482. UI.addUser = function (user) {
  483. var id = user.getId();
  484. var displayName = user.getDisplayName();
  485. UI.hideRingOverLay();
  486. if (UI.ContactList)
  487. UI.ContactList.addContact(id);
  488. messageHandler.notify(
  489. displayName,'notify.somebody', 'connected', 'notify.connected'
  490. );
  491. if (!config.startAudioMuted ||
  492. config.startAudioMuted > APP.conference.membersCount)
  493. UIUtil.playSoundNotification('userJoined');
  494. // Add Peer's container
  495. VideoLayout.addParticipantContainer(user);
  496. // Configure avatar
  497. UI.setUserEmail(id);
  498. // set initial display name
  499. if(displayName)
  500. UI.changeDisplayName(id, displayName);
  501. };
  502. /**
  503. * Remove user from UI.
  504. * @param {string} id user id
  505. * @param {string} displayName user nickname
  506. */
  507. UI.removeUser = function (id, displayName) {
  508. if (UI.ContactList)
  509. UI.ContactList.removeContact(id);
  510. messageHandler.notify(
  511. displayName,'notify.somebody', 'disconnected', 'notify.disconnected'
  512. );
  513. if (!config.startAudioMuted
  514. || config.startAudioMuted > APP.conference.membersCount) {
  515. UIUtil.playSoundNotification('userLeft');
  516. }
  517. VideoLayout.removeParticipantContainer(id);
  518. };
  519. /**
  520. * Update videotype for specified user.
  521. * @param {string} id user id
  522. * @param {string} newVideoType new videotype
  523. */
  524. UI.onPeerVideoTypeChanged = (id, newVideoType) => {
  525. VideoLayout.onVideoTypeChanged(id, newVideoType);
  526. };
  527. /**
  528. * Update local user role and show notification if user is moderator.
  529. * @param {boolean} isModerator if local user is moderator or not
  530. */
  531. UI.updateLocalRole = function (isModerator) {
  532. VideoLayout.showModeratorIndicator();
  533. Toolbar.showSipCallButton(isModerator);
  534. Toolbar.showSharedVideoButton(isModerator);
  535. Recording.showRecordingButton(isModerator);
  536. SettingsMenu.showStartMutedOptions(isModerator);
  537. SettingsMenu.showFollowMeOptions(isModerator);
  538. if (isModerator) {
  539. if (!interfaceConfig.DISABLE_FOCUS_INDICATOR)
  540. messageHandler
  541. .notify(null, "notify.me", 'connected', "notify.moderator");
  542. Recording.checkAutoRecord();
  543. }
  544. };
  545. /**
  546. * Check the role for the user and reflect it in the UI, moderator ui indication
  547. * and notifies user who is the moderator
  548. * @param user to check for moderator
  549. */
  550. UI.updateUserRole = function (user) {
  551. VideoLayout.showModeratorIndicator();
  552. // We don't need to show moderator notifications when the focus (moderator)
  553. // indicator is disabled.
  554. if (!user.isModerator() || interfaceConfig.DISABLE_FOCUS_INDICATOR) {
  555. return;
  556. }
  557. var displayName = user.getDisplayName();
  558. if (displayName) {
  559. messageHandler.notify(
  560. displayName, 'notify.somebody',
  561. 'connected', 'notify.grantedTo', {
  562. to: UIUtil.escapeHtml(displayName)
  563. }
  564. );
  565. } else {
  566. messageHandler.notify(
  567. '', 'notify.somebody',
  568. 'connected', 'notify.grantedToUnknown', {}
  569. );
  570. }
  571. };
  572. /**
  573. * Toggles smileys in the chat.
  574. */
  575. UI.toggleSmileys = function () {
  576. Chat.toggleSmileys();
  577. };
  578. /**
  579. * Toggles film strip.
  580. */
  581. UI.toggleFilmStrip = function () {
  582. var self = FilmStrip;
  583. self.toggleFilmStrip.apply(self, arguments);
  584. VideoLayout.resizeVideoArea(true, false);
  585. };
  586. /**
  587. * Indicates if the film strip is currently visible or not.
  588. * @returns {true} if the film strip is currently visible, otherwise
  589. */
  590. UI.isFilmStripVisible = function () {
  591. return FilmStrip.isFilmStripVisible();
  592. };
  593. /**
  594. * Toggles chat panel.
  595. */
  596. UI.toggleChat = function () {
  597. UI.toggleSidePanel("chat_container");
  598. };
  599. /**
  600. * Toggles contact list panel.
  601. */
  602. UI.toggleContactList = function () {
  603. UI.toggleSidePanel("contacts_container");
  604. };
  605. /**
  606. * Toggles the given side panel.
  607. *
  608. * @param {String} sidePanelId the identifier of the side panel to toggle
  609. */
  610. UI.toggleSidePanel = function (sidePanelId) {
  611. SideContainerToggler.toggle(sidePanelId);
  612. };
  613. /**
  614. * Handle new user display name.
  615. */
  616. UI.inputDisplayNameHandler = function (newDisplayName) {
  617. eventEmitter.emit(UIEvents.NICKNAME_CHANGED, newDisplayName);
  618. };
  619. /**
  620. * Return the type of the remote video.
  621. * @param jid the jid for the remote video
  622. * @returns the video type video or screen.
  623. */
  624. UI.getRemoteVideoType = function (jid) {
  625. return VideoLayout.getRemoteVideoType(jid);
  626. };
  627. UI.connectionIndicatorShowMore = function(id) {
  628. VideoLayout.showMore(id);
  629. return false;
  630. };
  631. // FIXME check if someone user this
  632. UI.showLoginPopup = function(callback) {
  633. console.log('password is required');
  634. let message = (
  635. `<input name="username" type="text"
  636. placeholder="user@domain.net" autofocus>
  637. <input name="password" type="password"
  638. data-i18n="[placeholder]dialog.userPassword"
  639. placeholder="user password">`
  640. );
  641. let submitFunction = (e, v, m, f) => {
  642. if (v) {
  643. if (f.username && f.password) {
  644. callback(f.username, f.password);
  645. }
  646. }
  647. };
  648. messageHandler.openTwoButtonDialog({
  649. titleKey : "dialog.passwordRequired",
  650. msgString: message,
  651. leftButtonKey: 'dialog.Ok',
  652. submitFunction,
  653. focus: ':input:first'
  654. });
  655. };
  656. UI.askForNickname = function () {
  657. return window.prompt('Your nickname (optional)');
  658. };
  659. /**
  660. * Sets muted audio state for participant
  661. */
  662. UI.setAudioMuted = function (id, muted) {
  663. VideoLayout.onAudioMute(id, muted);
  664. if (APP.conference.isLocalId(id)) {
  665. Toolbar.toggleAudioIcon(muted);
  666. }
  667. };
  668. /**
  669. * Sets muted video state for participant
  670. */
  671. UI.setVideoMuted = function (id, muted) {
  672. VideoLayout.onVideoMute(id, muted);
  673. if (APP.conference.isLocalId(id)) {
  674. Toolbar.toggleVideoIcon(muted);
  675. }
  676. };
  677. /**
  678. * Adds a listener that would be notified on the given type of event.
  679. *
  680. * @param type the type of the event we're listening for
  681. * @param listener a function that would be called when notified
  682. */
  683. UI.addListener = function (type, listener) {
  684. eventEmitter.on(type, listener);
  685. };
  686. /**
  687. * Removes the given listener for the given type of event.
  688. *
  689. * @param type the type of the event we're listening for
  690. * @param listener the listener we want to remove
  691. */
  692. UI.removeListener = function (type, listener) {
  693. eventEmitter.removeListener(type, listener);
  694. };
  695. /**
  696. * Emits the event of given type by specifying the parameters in options.
  697. *
  698. * @param type the type of the event we're emitting
  699. * @param options the parameters for the event
  700. */
  701. UI.emitEvent = function (type, options) {
  702. eventEmitter.emit(type, options);
  703. };
  704. UI.clickOnVideo = function (videoNumber) {
  705. let videos = $("#remoteVideos .videocontainer:not(#mixedstream)").toArray();
  706. // Separate remotes from local videocontainer and reverse order of
  707. // remote ones
  708. let videosMap = videos.reduce((videoObj, video) => {
  709. if(video.id === 'localVideoContainer') {
  710. videoObj.local = video;
  711. } else {
  712. videoObj.remote.unshift(video);
  713. }
  714. return videoObj;
  715. }, { local: null, remote: [] });
  716. let sortedVideos = [videosMap.local, ...videosMap.remote];
  717. if (sortedVideos.length > videoNumber) {
  718. $(sortedVideos[videoNumber]).click();
  719. }
  720. };
  721. //Used by torture
  722. UI.showToolbar = function (timeout) {
  723. return ToolbarToggler.showToolbar(timeout);
  724. };
  725. //Used by torture
  726. UI.dockToolbar = function (isDock) {
  727. ToolbarToggler.dockToolbar(isDock);
  728. };
  729. /**
  730. * Updates the avatar for participant.
  731. * @param {string} id user id
  732. * @param {string} avatarUrl the URL for the avatar
  733. */
  734. function changeAvatar(id, avatarUrl) {
  735. VideoLayout.changeUserAvatar(id, avatarUrl);
  736. if (UI.ContactList)
  737. UI.ContactList.changeUserAvatar(id, avatarUrl);
  738. if (APP.conference.isLocalId(id)) {
  739. Profile.changeAvatar(avatarUrl);
  740. }
  741. }
  742. /**
  743. * Update user email.
  744. * @param {string} id user id
  745. * @param {string} email user email
  746. */
  747. UI.setUserEmail = function (id, email) {
  748. // update avatar
  749. Avatar.setUserEmail(id, email);
  750. changeAvatar(id, Avatar.getAvatarUrl(id));
  751. };
  752. /**
  753. * Update user avtar id.
  754. * @param {string} id user id
  755. * @param {string} avatarId user's avatar id
  756. */
  757. UI.setUserAvatarID = function (id, avatarId) {
  758. // update avatar
  759. Avatar.setUserAvatarID(id, avatarId);
  760. changeAvatar(id, Avatar.getAvatarUrl(id));
  761. };
  762. /**
  763. * Update user avatar URL.
  764. * @param {string} id user id
  765. * @param {string} url user avatar url
  766. */
  767. UI.setUserAvatarUrl = function (id, url) {
  768. // update avatar
  769. Avatar.setUserAvatarUrl(id, url);
  770. changeAvatar(id, Avatar.getAvatarUrl(id));
  771. };
  772. /**
  773. * Notify user that connection failed.
  774. * @param {string} stropheErrorMsg raw Strophe error message
  775. */
  776. UI.notifyConnectionFailed = function (stropheErrorMsg) {
  777. var message;
  778. if (stropheErrorMsg) {
  779. message = APP.translation.generateTranslationHTML(
  780. "dialog.connectErrorWithMsg", {msg: stropheErrorMsg});
  781. } else {
  782. message = APP.translation.generateTranslationHTML(
  783. "dialog.connectError");
  784. }
  785. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  786. };
  787. /**
  788. * Notify user that maximum users limit has been reached.
  789. */
  790. UI.notifyMaxUsersLimitReached = function () {
  791. var message = APP.translation.generateTranslationHTML(
  792. "dialog.maxUsersLimitReached");
  793. messageHandler.openDialog("dialog.error", message, true, {}, () => false);
  794. };
  795. /**
  796. * Notify user that he was automatically muted when joned the conference.
  797. */
  798. UI.notifyInitiallyMuted = function () {
  799. messageHandler.notify(
  800. null,
  801. "notify.mutedTitle",
  802. "connected",
  803. "notify.muted",
  804. null,
  805. { timeOut: 120000 });
  806. };
  807. /**
  808. * Mark user as dominant speaker.
  809. * @param {string} id user id
  810. */
  811. UI.markDominantSpeaker = function (id) {
  812. VideoLayout.onDominantSpeakerChanged(id);
  813. };
  814. UI.handleLastNEndpoints = function (ids, enteringIds) {
  815. VideoLayout.onLastNEndpointsChanged(ids, enteringIds);
  816. };
  817. /**
  818. * Will handle notification about participant's connectivity status change.
  819. *
  820. * @param {string} id the id of remote participant(MUC jid)
  821. * @param {boolean} isActive true if the connection is ok or false if the user
  822. * is having connectivity issues.
  823. */
  824. UI.participantConnectionStatusChanged = function (id, isActive) {
  825. VideoLayout.onParticipantConnectionStatusChanged(id, isActive);
  826. };
  827. /**
  828. * Update audio level visualization for specified user.
  829. * @param {string} id user id
  830. * @param {number} lvl audio level
  831. */
  832. UI.setAudioLevel = function (id, lvl) {
  833. VideoLayout.setAudioLevel(id, lvl);
  834. };
  835. /**
  836. * Update state of desktop sharing buttons.
  837. */
  838. UI.updateDesktopSharingButtons = function () {
  839. Toolbar.updateDesktopSharingButtonState();
  840. };
  841. /**
  842. * Hide connection quality statistics from UI.
  843. */
  844. UI.hideStats = function () {
  845. VideoLayout.hideStats();
  846. };
  847. /**
  848. * Update local connection quality statistics.
  849. * @param {number} percent
  850. * @param {object} stats
  851. */
  852. UI.updateLocalStats = function (percent, stats) {
  853. VideoLayout.updateLocalConnectionStats(percent, stats);
  854. };
  855. /**
  856. * Update connection quality statistics for remote user.
  857. * @param {string} id user id
  858. * @param {number} percent
  859. * @param {object} stats
  860. */
  861. UI.updateRemoteStats = function (id, percent, stats) {
  862. VideoLayout.updateConnectionStats(id, percent, stats);
  863. };
  864. /**
  865. * Mark video as interrupted or not.
  866. * @param {boolean} interrupted if video is interrupted
  867. */
  868. UI.markVideoInterrupted = function (interrupted) {
  869. if (interrupted) {
  870. VideoLayout.onVideoInterrupted();
  871. } else {
  872. VideoLayout.onVideoRestored();
  873. }
  874. };
  875. /**
  876. * Add chat message.
  877. * @param {string} from user id
  878. * @param {string} displayName user nickname
  879. * @param {string} message message text
  880. * @param {number} stamp timestamp when message was created
  881. */
  882. UI.addMessage = function (from, displayName, message, stamp) {
  883. Chat.updateChatConversation(from, displayName, message, stamp);
  884. };
  885. // eslint-disable-next-line no-unused-vars
  886. UI.updateDTMFSupport = function (isDTMFSupported) {
  887. //TODO: enable when the UI is ready
  888. //Toolbar.showDialPadButton(isDTMFSupported);
  889. };
  890. /**
  891. * Show user feedback dialog if its required and enabled after pressing the
  892. * hangup button.
  893. * @returns {Promise} Resolved with value - false if the dialog is enabled and
  894. * resolved with true if the dialog is disabled or the feedback was already
  895. * submitted. Rejected if another dialog is already displayed. This values are
  896. * used to display or not display the thank you dialog from
  897. * conference.maybeRedirectToWelcomePage method.
  898. */
  899. UI.requestFeedbackOnHangup = function () {
  900. if (Feedback.isVisible())
  901. return Promise.reject(UIErrors.FEEDBACK_REQUEST_IN_PROGRESS);
  902. // Feedback has been submitted already.
  903. else if (Feedback.isEnabled() && Feedback.isSubmitted()) {
  904. return Promise.resolve({
  905. thankYouDialogVisible : true,
  906. feedbackSubmitted: true
  907. });
  908. }
  909. else
  910. return new Promise(function (resolve) {
  911. if (Feedback.isEnabled()) {
  912. Feedback.openFeedbackWindow(
  913. (options) => {
  914. options.thankYouDialogVisible = false;
  915. resolve(options);
  916. });
  917. } else {
  918. // If the feedback functionality isn't enabled we show a thank
  919. // you dialog. Signaling it (true), so the caller
  920. // of requestFeedback can act on it
  921. resolve(
  922. {thankYouDialogVisible : true, feedbackSubmitted: false});
  923. }
  924. });
  925. };
  926. UI.updateRecordingState = function (state) {
  927. Recording.updateRecordingState(state);
  928. };
  929. UI.notifyTokenAuthFailed = function () {
  930. messageHandler.showError( "dialog.tokenAuthFailedTitle",
  931. "dialog.tokenAuthFailed");
  932. };
  933. UI.notifyInternalError = function () {
  934. messageHandler.showError( "dialog.internalErrorTitle",
  935. "dialog.internalError");
  936. };
  937. UI.notifyFocusDisconnected = function (focus, retrySec) {
  938. messageHandler.notify(
  939. null, "notify.focus",
  940. 'disconnected', "notify.focusFail",
  941. {component: focus, ms: retrySec}
  942. );
  943. };
  944. /**
  945. * Notify the user that the video conferencing service is badly broken and
  946. * the page should be reloaded.
  947. */
  948. UI.showPageReloadOverlay = function () {
  949. // Reload the page after 10 - 30 seconds
  950. PageReloadOverlay.show(10 + RandomUtil.randomInt(0, 20));
  951. };
  952. /**
  953. * Updates auth info on the UI.
  954. * @param {boolean} isAuthEnabled if authentication is enabled
  955. * @param {string} [login] current login
  956. */
  957. UI.updateAuthInfo = function (isAuthEnabled, login) {
  958. let showAuth = isAuthEnabled && UIUtil.isAuthenticationEnabled();
  959. let loggedIn = !!login;
  960. Toolbar.showAuthenticateButton(showAuth);
  961. if (showAuth) {
  962. Toolbar.setAuthenticatedIdentity(login);
  963. Toolbar.showLoginButton(!loggedIn);
  964. Toolbar.showLogoutButton(loggedIn);
  965. }
  966. };
  967. UI.onStartMutedChanged = function (startAudioMuted, startVideoMuted) {
  968. SettingsMenu.updateStartMutedBox(startAudioMuted, startVideoMuted);
  969. };
  970. /**
  971. * Notifies interested listeners that the raise hand property has changed.
  972. *
  973. * @param {boolean} isRaisedHand indicates the current state of the
  974. * "raised hand"
  975. */
  976. UI.onLocalRaiseHandChanged = function (isRaisedHand) {
  977. eventEmitter.emit(UIEvents.LOCAL_RAISE_HAND_CHANGED, isRaisedHand);
  978. };
  979. /**
  980. * Update list of available physical devices.
  981. * @param {object[]} devices new list of available devices
  982. */
  983. UI.onAvailableDevicesChanged = function (devices) {
  984. SettingsMenu.changeDevicesList(devices);
  985. };
  986. /**
  987. * Sets microphone's <select> element to select microphone ID from settings.
  988. */
  989. UI.setSelectedMicFromSettings = function () {
  990. SettingsMenu.setSelectedMicFromSettings();
  991. };
  992. /**
  993. * Sets camera's <select> element to select camera ID from settings.
  994. */
  995. UI.setSelectedCameraFromSettings = function () {
  996. SettingsMenu.setSelectedCameraFromSettings();
  997. };
  998. /**
  999. * Sets audio outputs's <select> element to select audio output ID from
  1000. * settings.
  1001. */
  1002. UI.setSelectedAudioOutputFromSettings = function () {
  1003. SettingsMenu.setSelectedAudioOutputFromSettings();
  1004. };
  1005. /**
  1006. * Returns the id of the current video shown on large.
  1007. * Currently used by tests (torture).
  1008. */
  1009. UI.getLargeVideoID = function () {
  1010. return VideoLayout.getLargeVideoID();
  1011. };
  1012. /**
  1013. * Returns the current video shown on large.
  1014. * Currently used by tests (torture).
  1015. */
  1016. UI.getLargeVideo = function () {
  1017. return VideoLayout.getLargeVideo();
  1018. };
  1019. /**
  1020. * Shows dialog with a link to FF extension.
  1021. */
  1022. UI.showExtensionRequiredDialog = function (url) {
  1023. messageHandler.openMessageDialog(
  1024. "dialog.extensionRequired",
  1025. "dialog.firefoxExtensionPrompt",
  1026. {url: url});
  1027. };
  1028. /**
  1029. * Shows "Please go to chrome webstore to install the desktop sharing extension"
  1030. * 2 button dialog with buttons - cancel and go to web store.
  1031. * @param url {string} the url of the extension.
  1032. */
  1033. UI.showExtensionExternalInstallationDialog = function (url) {
  1034. let submitFunction = function(e,v){
  1035. if (v) {
  1036. e.preventDefault();
  1037. eventEmitter.emit(UIEvents.OPEN_EXTENSION_STORE, url);
  1038. }
  1039. };
  1040. let closeFunction = function () {
  1041. eventEmitter.emit(UIEvents.EXTERNAL_INSTALLATION_CANCELED);
  1042. };
  1043. messageHandler.openTwoButtonDialog({
  1044. titleKey: 'dialog.externalInstallationTitle',
  1045. msgKey: 'dialog.externalInstallationMsg',
  1046. leftButtonKey: 'dialog.goToStore',
  1047. submitFunction,
  1048. loadedFunction: $.noop,
  1049. closeFunction
  1050. });
  1051. };
  1052. /**
  1053. * Shows dialog with combined information about camera and microphone errors.
  1054. * @param {JitsiTrackError} micError
  1055. * @param {JitsiTrackError} cameraError
  1056. */
  1057. UI.showDeviceErrorDialog = function (micError, cameraError) {
  1058. let dontShowAgain = {
  1059. id: "doNotShowWarningAgain",
  1060. localStorageKey: "doNotShowErrorAgain",
  1061. textKey: "dialog.doNotShowWarningAgain"
  1062. };
  1063. let isMicJitsiTrackErrorAndHasName = micError && micError.name &&
  1064. micError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1065. let isCameraJitsiTrackErrorAndHasName = cameraError && cameraError.name &&
  1066. cameraError instanceof JitsiMeetJS.errorTypes.JitsiTrackError;
  1067. let showDoNotShowWarning = false;
  1068. if (micError && cameraError && isMicJitsiTrackErrorAndHasName &&
  1069. isCameraJitsiTrackErrorAndHasName) {
  1070. showDoNotShowWarning = true;
  1071. } else if (micError && isMicJitsiTrackErrorAndHasName && !cameraError) {
  1072. showDoNotShowWarning = true;
  1073. } else if (cameraError && isCameraJitsiTrackErrorAndHasName && !micError) {
  1074. showDoNotShowWarning = true;
  1075. }
  1076. if (micError) {
  1077. dontShowAgain.localStorageKey += "-mic-" + micError.name;
  1078. }
  1079. if (cameraError) {
  1080. dontShowAgain.localStorageKey += "-camera-" + cameraError.name;
  1081. }
  1082. let cameraJitsiTrackErrorMsg = cameraError
  1083. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[cameraError.name]
  1084. : undefined;
  1085. let micJitsiTrackErrorMsg = micError
  1086. ? JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[micError.name]
  1087. : undefined;
  1088. let cameraErrorMsg = cameraError
  1089. ? cameraJitsiTrackErrorMsg ||
  1090. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.camera[TrackErrors.GENERAL]
  1091. : "";
  1092. let micErrorMsg = micError
  1093. ? micJitsiTrackErrorMsg ||
  1094. JITSI_TRACK_ERROR_TO_MESSAGE_KEY_MAP.microphone[TrackErrors.GENERAL]
  1095. : "";
  1096. let additionalCameraErrorMsg = !cameraJitsiTrackErrorMsg && cameraError &&
  1097. cameraError.message
  1098. ? `<div>${cameraError.message}</div>`
  1099. : ``;
  1100. let additionalMicErrorMsg = !micJitsiTrackErrorMsg && micError &&
  1101. micError.message
  1102. ? `<div>${micError.message}</div>`
  1103. : ``;
  1104. let message = '';
  1105. if (micError) {
  1106. message = `
  1107. ${message}
  1108. <h3 data-i18n='dialog.micErrorPresent'></h3>
  1109. <h4 data-i18n='${micErrorMsg}'></h4>
  1110. ${additionalMicErrorMsg}`;
  1111. }
  1112. if (cameraError) {
  1113. message = `
  1114. ${message}
  1115. <h3 data-i18n='dialog.cameraErrorPresent'></h3>
  1116. <h4 data-i18n='${cameraErrorMsg}'></h4>
  1117. ${additionalCameraErrorMsg}`;
  1118. }
  1119. // To make sure we don't have multiple error dialogs open at the same time,
  1120. // we will just close the previous one if we are going to show a new one.
  1121. deviceErrorDialog && deviceErrorDialog.close();
  1122. deviceErrorDialog = messageHandler.openDialog(
  1123. getTitleKey(),
  1124. message,
  1125. false,
  1126. {Ok: true},
  1127. function () {},
  1128. null,
  1129. function () {
  1130. // Reset dialog reference to null to avoid memory leaks when
  1131. // user closed the dialog manually.
  1132. deviceErrorDialog = null;
  1133. },
  1134. showDoNotShowWarning ? dontShowAgain : undefined
  1135. );
  1136. function getTitleKey() {
  1137. let title = "dialog.error";
  1138. if (micError && micError.name === TrackErrors.PERMISSION_DENIED) {
  1139. if (!cameraError
  1140. || cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1141. title = "dialog.permissionDenied";
  1142. }
  1143. } else if (cameraError
  1144. && cameraError.name === TrackErrors.PERMISSION_DENIED) {
  1145. title = "dialog.permissionDenied";
  1146. }
  1147. return title;
  1148. }
  1149. };
  1150. /**
  1151. * Shows error dialog that informs the user that no data is received from the
  1152. * device.
  1153. */
  1154. UI.showTrackNotWorkingDialog = function (stream) {
  1155. messageHandler.openMessageDialog(
  1156. "dialog.error",
  1157. stream.isAudioTrack()? "dialog.micNotSendingData" :
  1158. "dialog.cameraNotSendingData");
  1159. };
  1160. UI.updateDevicesAvailability = function (id, devices) {
  1161. VideoLayout.setDeviceAvailabilityIcons(id, devices);
  1162. };
  1163. /**
  1164. * Show shared video.
  1165. * @param {string} id the id of the sender of the command
  1166. * @param {string} url video url
  1167. * @param {string} attributes
  1168. */
  1169. UI.onSharedVideoStart = function (id, url, attributes) {
  1170. if (sharedVideoManager)
  1171. sharedVideoManager.onSharedVideoStart(id, url, attributes);
  1172. };
  1173. /**
  1174. * Update shared video.
  1175. * @param {string} id the id of the sender of the command
  1176. * @param {string} url video url
  1177. * @param {string} attributes
  1178. */
  1179. UI.onSharedVideoUpdate = function (id, url, attributes) {
  1180. if (sharedVideoManager)
  1181. sharedVideoManager.onSharedVideoUpdate(id, url, attributes);
  1182. };
  1183. /**
  1184. * Stop showing shared video.
  1185. * @param {string} id the id of the sender of the command
  1186. * @param {string} attributes
  1187. */
  1188. UI.onSharedVideoStop = function (id, attributes) {
  1189. if (sharedVideoManager)
  1190. sharedVideoManager.onSharedVideoStop(id, attributes);
  1191. };
  1192. /**
  1193. * Enables / disables camera toolbar button.
  1194. *
  1195. * @param {boolean} enabled indicates if the camera button should be enabled
  1196. * or disabled
  1197. */
  1198. UI.setCameraButtonEnabled = function (enabled) {
  1199. Toolbar.setVideoIconEnabled(enabled);
  1200. };
  1201. /**
  1202. * Enables / disables microphone toolbar button.
  1203. *
  1204. * @param {boolean} enabled indicates if the microphone button should be
  1205. * enabled or disabled
  1206. */
  1207. UI.setMicrophoneButtonEnabled = function (enabled) {
  1208. Toolbar.setAudioIconEnabled(enabled);
  1209. };
  1210. UI.showRingOverlay = function () {
  1211. RingOverlay.show(APP.tokenData.callee, interfaceConfig.DISABLE_RINGING);
  1212. FilmStrip.toggleFilmStrip(false);
  1213. };
  1214. UI.hideRingOverLay = function () {
  1215. if (!RingOverlay.hide())
  1216. return;
  1217. FilmStrip.toggleFilmStrip(true);
  1218. };
  1219. /**
  1220. * Indicates if any the "top" overlays are currently visible. The check includes
  1221. * the call overlay, GUM permissions overlay and a page reload overlay.
  1222. *
  1223. * @returns {*|boolean} {true} if the overlay is visible, {false} otherwise
  1224. */
  1225. UI.isOverlayVisible = function () {
  1226. return RingOverlay.isVisible()
  1227. || PageReloadOverlay.isVisible()
  1228. || GumPermissionsOverlay.isVisible();
  1229. };
  1230. /**
  1231. * Indicates if the ring overlay is currently visible.
  1232. *
  1233. * @returns {*|boolean} {true} if the ring overlay is visible, {false} otherwise
  1234. */
  1235. UI.isRingOverlayVisible = function () {
  1236. return RingOverlay.isVisible();
  1237. };
  1238. /**
  1239. * Shows browser-specific overlay with guidance how to proceed with gUM prompt.
  1240. * @param {string} browser - name of browser for which to show the guidance
  1241. * overlay.
  1242. */
  1243. UI.showUserMediaPermissionsGuidanceOverlay = function (browser) {
  1244. GumPermissionsOverlay.show(browser);
  1245. };
  1246. /**
  1247. * Hides browser-specific overlay with guidance how to proceed with gUM prompt.
  1248. */
  1249. UI.hideUserMediaPermissionsGuidanceOverlay = function () {
  1250. GumPermissionsOverlay.hide();
  1251. };
  1252. module.exports = UI;