您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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