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

defaultToolbarButtons.web.js 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. // @flow
  2. import React from 'react';
  3. import {
  4. SHORTCUT_AUDIO_MUTE_TOGGLED,
  5. SHORTCUT_CHAT_TOGGLED,
  6. SHORTCUT_RAISE_HAND_CLICKED,
  7. SHORTCUT_SCREEN_TOGGLED,
  8. SHORTCUT_VIDEO_MUTE_TOGGLED,
  9. TOOLBAR_AUDIO_MUTED,
  10. TOOLBAR_AUDIO_UNMUTED,
  11. TOOLBAR_CHAT_TOGGLED,
  12. TOOLBAR_CONTACTS_TOGGLED,
  13. TOOLBAR_ETHERPACK_CLICKED,
  14. TOOLBAR_FILMSTRIP_ONLY_DEVICE_SELECTION_TOGGLED,
  15. TOOLBAR_FULLSCREEN_ENABLED,
  16. TOOLBAR_HANGUP,
  17. TOOLBAR_INVITE_CLICKED,
  18. TOOLBAR_RAISE_HAND_CLICKED,
  19. TOOLBAR_SCREEN_DISABLED,
  20. TOOLBAR_SCREEN_ENABLED,
  21. TOOLBAR_SETTINGS_TOGGLED,
  22. TOOLBAR_SHARED_VIDEO_CLICKED,
  23. TOOLBAR_SIP_DIALPAD_CLICKED,
  24. TOOLBAR_VIDEO_DISABLED,
  25. TOOLBAR_VIDEO_ENABLED,
  26. sendAnalyticsEvent
  27. } from '../analytics';
  28. import { ParticipantCounter } from '../contact-list';
  29. import { openDeviceSelectionDialog } from '../device-selection';
  30. import { InfoDialogButton, openInviteDialog } from '../invite';
  31. import UIEvents from '../../../service/UI/UIEvents';
  32. import { VideoQualityButton } from '../video-quality';
  33. import ProfileButton from './components/ProfileButton';
  34. declare var APP: Object;
  35. declare var interfaceConfig: Object;
  36. /**
  37. * The cache of {@link getDefaultButtons()}.
  38. */
  39. let defaultButtons: Object;
  40. /**
  41. * Returns a map of all button descriptors and according properties.
  42. *
  43. * @returns {Object} - The maps of default button descriptors.
  44. */
  45. export default function getDefaultButtons() {
  46. if (defaultButtons) {
  47. return defaultButtons;
  48. }
  49. defaultButtons = {
  50. /**
  51. * The descriptor of the camera toolbar button.
  52. */
  53. camera: {
  54. classNames: [ 'button', 'icon-camera' ],
  55. enabled: true,
  56. isDisplayed: () => true,
  57. id: 'toolbar_button_camera',
  58. onClick() {
  59. const newVideoMutedState = !APP.conference.isLocalVideoMuted();
  60. if (newVideoMutedState) {
  61. sendAnalyticsEvent(TOOLBAR_VIDEO_ENABLED);
  62. } else {
  63. sendAnalyticsEvent(TOOLBAR_VIDEO_DISABLED);
  64. }
  65. APP.UI.emitEvent(UIEvents.VIDEO_MUTED, newVideoMutedState);
  66. },
  67. popups: [
  68. {
  69. dataAttr: 'audioOnly.featureToggleDisabled',
  70. dataInterpolate: { feature: 'video mute' },
  71. id: 'unmuteWhileAudioOnly'
  72. }
  73. ],
  74. shortcut: 'V',
  75. shortcutAttr: 'toggleVideoPopover',
  76. shortcutFunc() {
  77. if (APP.conference.isAudioOnly()) {
  78. APP.UI.emitEvent(UIEvents.VIDEO_UNMUTING_WHILE_AUDIO_ONLY);
  79. return;
  80. }
  81. sendAnalyticsEvent(SHORTCUT_VIDEO_MUTE_TOGGLED);
  82. APP.conference.toggleVideoMuted();
  83. },
  84. shortcutDescription: 'keyboardShortcuts.videoMute',
  85. tooltipKey: 'toolbar.videomute'
  86. },
  87. /**
  88. * The descriptor of the chat toolbar button.
  89. */
  90. chat: {
  91. classNames: [ 'button', 'icon-chat' ],
  92. enabled: true,
  93. html: <span className = 'badge-round'>
  94. <span id = 'unreadMessages' /></span>,
  95. id: 'toolbar_button_chat',
  96. onClick() {
  97. sendAnalyticsEvent(TOOLBAR_CHAT_TOGGLED);
  98. APP.UI.emitEvent(UIEvents.TOGGLE_CHAT);
  99. },
  100. shortcut: 'C',
  101. shortcutAttr: 'toggleChatPopover',
  102. shortcutFunc() {
  103. sendAnalyticsEvent(SHORTCUT_CHAT_TOGGLED);
  104. APP.UI.toggleChat();
  105. },
  106. shortcutDescription: 'keyboardShortcuts.toggleChat',
  107. sideContainerId: 'chat_container',
  108. tooltipKey: 'toolbar.chat'
  109. },
  110. /**
  111. * The descriptor of the contact list toolbar button.
  112. */
  113. contacts: {
  114. childComponent: ParticipantCounter,
  115. classNames: [ 'button', 'icon-contactList' ],
  116. enabled: true,
  117. id: 'toolbar_contact_list',
  118. onClick() {
  119. sendAnalyticsEvent(TOOLBAR_CONTACTS_TOGGLED);
  120. APP.UI.emitEvent(UIEvents.TOGGLE_CONTACT_LIST);
  121. },
  122. sideContainerId: 'contacts_container',
  123. tooltipKey: 'bottomtoolbar.contactlist'
  124. },
  125. /**
  126. * The descriptor of the desktop sharing toolbar button.
  127. */
  128. desktop: {
  129. classNames: [ 'button', 'icon-share-desktop' ],
  130. enabled: true,
  131. id: 'toolbar_button_desktopsharing',
  132. onClick() {
  133. if (APP.conference.isSharingScreen) {
  134. sendAnalyticsEvent(TOOLBAR_SCREEN_DISABLED);
  135. } else {
  136. sendAnalyticsEvent(TOOLBAR_SCREEN_ENABLED);
  137. }
  138. APP.UI.emitEvent(UIEvents.TOGGLE_SCREENSHARING);
  139. },
  140. popups: [
  141. {
  142. dataAttr: 'audioOnly.featureToggleDisabled',
  143. dataInterpolate: { feature: 'screen sharing' },
  144. id: 'screenshareWhileAudioOnly'
  145. }
  146. ],
  147. shortcut: 'D',
  148. shortcutAttr: 'toggleDesktopSharingPopover',
  149. shortcutFunc() {
  150. sendAnalyticsEvent(SHORTCUT_SCREEN_TOGGLED);
  151. // eslint-disable-next-line no-empty-function
  152. APP.conference.toggleScreenSharing().catch(() => {});
  153. },
  154. shortcutDescription: 'keyboardShortcuts.toggleScreensharing',
  155. tooltipKey: 'toolbar.sharescreen'
  156. },
  157. /**
  158. * The descriptor of the device selection toolbar button.
  159. */
  160. fodeviceselection: {
  161. classNames: [ 'button', 'icon-settings' ],
  162. enabled: true,
  163. isDisplayed() {
  164. return interfaceConfig.filmStripOnly;
  165. },
  166. id: 'toolbar_button_fodeviceselection',
  167. onClick(dispatch: Function) {
  168. sendAnalyticsEvent(
  169. TOOLBAR_FILMSTRIP_ONLY_DEVICE_SELECTION_TOGGLED);
  170. dispatch(openDeviceSelectionDialog());
  171. },
  172. sideContainerId: 'settings_container',
  173. tooltipKey: 'toolbar.Settings'
  174. },
  175. /**
  176. * The descriptor of the dialpad toolbar button.
  177. */
  178. dialpad: {
  179. classNames: [ 'button', 'icon-dialpad' ],
  180. enabled: true,
  181. // TODO: remove it after UI.updateDTMFSupport fix
  182. hidden: true,
  183. id: 'toolbar_button_dialpad',
  184. onClick() {
  185. sendAnalyticsEvent(TOOLBAR_SIP_DIALPAD_CLICKED);
  186. },
  187. tooltipKey: 'toolbar.dialpad'
  188. },
  189. /**
  190. * The descriptor of the etherpad toolbar button.
  191. */
  192. etherpad: {
  193. classNames: [ 'button', 'icon-share-doc' ],
  194. enabled: true,
  195. hidden: true,
  196. id: 'toolbar_button_etherpad',
  197. onClick() {
  198. sendAnalyticsEvent(TOOLBAR_ETHERPACK_CLICKED);
  199. APP.UI.emitEvent(UIEvents.ETHERPAD_CLICKED);
  200. },
  201. tooltipKey: 'toolbar.etherpad'
  202. },
  203. /**
  204. * The descriptor of the toolbar button which toggles full-screen mode.
  205. */
  206. fullscreen: {
  207. classNames: [ 'button', 'icon-full-screen' ],
  208. enabled: true,
  209. id: 'toolbar_button_fullScreen',
  210. onClick() {
  211. sendAnalyticsEvent(TOOLBAR_FULLSCREEN_ENABLED);
  212. APP.UI.emitEvent(UIEvents.TOGGLE_FULLSCREEN);
  213. },
  214. shortcut: 'S',
  215. shortcutAttr: 'toggleFullscreenPopover',
  216. shortcutDescription: 'keyboardShortcuts.fullScreen',
  217. shortcutFunc() {
  218. sendAnalyticsEvent('shortcut.fullscreen.toggled');
  219. APP.UI.toggleFullScreen();
  220. },
  221. tooltipKey: 'toolbar.fullscreen'
  222. },
  223. /**
  224. * The descriptor of the toolbar button which hangs up the
  225. * call/conference.
  226. */
  227. hangup: {
  228. classNames: [ 'button', 'icon-hangup', 'button_hangup' ],
  229. enabled: true,
  230. isDisplayed: () => true,
  231. id: 'toolbar_button_hangup',
  232. onClick() {
  233. sendAnalyticsEvent(TOOLBAR_HANGUP);
  234. APP.UI.emitEvent(UIEvents.HANGUP);
  235. },
  236. tooltipKey: 'toolbar.hangup'
  237. },
  238. /**
  239. * The descriptor of the toolbar button which opens a dialog for the
  240. * conference URL and inviting others.
  241. */
  242. info: {
  243. component: InfoDialogButton
  244. },
  245. /**
  246. * The descriptor of the toolbar button which shows the invite user
  247. * dialog.
  248. */
  249. invite: {
  250. classNames: [ 'button', 'icon-link' ],
  251. enabled: true,
  252. id: 'toolbar_button_link',
  253. onClick(dispatch: Function) {
  254. sendAnalyticsEvent(TOOLBAR_INVITE_CLICKED);
  255. dispatch(openInviteDialog());
  256. },
  257. tooltipKey: 'toolbar.invite'
  258. },
  259. /**
  260. * The descriptor of the microphone toolbar button.
  261. */
  262. microphone: {
  263. classNames: [ 'button', 'icon-microphone' ],
  264. enabled: true,
  265. isDisplayed: () => true,
  266. id: 'toolbar_button_mute',
  267. onClick() {
  268. const sharedVideoManager = APP.UI.getSharedVideoManager();
  269. if (APP.conference.isLocalAudioMuted()) {
  270. // If there's a shared video with the volume "on" and we
  271. // aren't the video owner, we warn the user
  272. // that currently it's not possible to unmute.
  273. if (sharedVideoManager
  274. && sharedVideoManager.isSharedVideoVolumeOn()
  275. && !sharedVideoManager.isSharedVideoOwner()) {
  276. APP.UI.showCustomToolbarPopup(
  277. 'microphone', 'unableToUnmutePopup', true, 5000);
  278. } else {
  279. sendAnalyticsEvent(TOOLBAR_AUDIO_UNMUTED);
  280. APP.UI.emitEvent(UIEvents.AUDIO_MUTED, false, true);
  281. }
  282. } else {
  283. sendAnalyticsEvent(TOOLBAR_AUDIO_MUTED);
  284. APP.UI.emitEvent(UIEvents.AUDIO_MUTED, true, true);
  285. }
  286. },
  287. popups: [
  288. {
  289. dataAttr: 'toolbar.micMutedPopup',
  290. id: 'micMutedPopup'
  291. },
  292. {
  293. dataAttr: 'toolbar.unableToUnmutePopup',
  294. id: 'unableToUnmutePopup'
  295. },
  296. {
  297. dataAttr: 'toolbar.talkWhileMutedPopup',
  298. id: 'talkWhileMutedPopup'
  299. }
  300. ],
  301. shortcut: 'M',
  302. shortcutAttr: 'mutePopover',
  303. shortcutFunc() {
  304. sendAnalyticsEvent(SHORTCUT_AUDIO_MUTE_TOGGLED);
  305. APP.conference.toggleAudioMuted();
  306. },
  307. shortcutDescription: 'keyboardShortcuts.mute',
  308. tooltipKey: 'toolbar.mute'
  309. },
  310. /**
  311. * The descriptor of the profile toolbar button.
  312. */
  313. profile: {
  314. component: ProfileButton,
  315. sideContainerId: 'profile_container'
  316. },
  317. /**
  318. * The descriptor of the "Raise hand" toolbar button.
  319. */
  320. raisehand: {
  321. classNames: [ 'button', 'icon-raised-hand' ],
  322. enabled: true,
  323. id: 'toolbar_button_raisehand',
  324. onClick() {
  325. sendAnalyticsEvent(TOOLBAR_RAISE_HAND_CLICKED);
  326. APP.conference.maybeToggleRaisedHand();
  327. },
  328. shortcut: 'R',
  329. shortcutAttr: 'raiseHandPopover',
  330. shortcutDescription: 'keyboardShortcuts.raiseHand',
  331. shortcutFunc() {
  332. sendAnalyticsEvent(SHORTCUT_RAISE_HAND_CLICKED);
  333. APP.conference.maybeToggleRaisedHand();
  334. },
  335. tooltipKey: 'toolbar.raiseHand'
  336. },
  337. /**
  338. * The descriptor of the recording toolbar button. Requires additional
  339. * initialization in the recording module.
  340. */
  341. recording: {
  342. classNames: [ 'button' ],
  343. enabled: true,
  344. // will be displayed once the recording functionality is detected
  345. hidden: true,
  346. id: 'toolbar_button_record',
  347. tooltipKey: 'liveStreaming.buttonTooltip'
  348. },
  349. /**
  350. * The descriptor of the settings toolbar button.
  351. */
  352. settings: {
  353. classNames: [ 'button', 'icon-settings' ],
  354. enabled: true,
  355. id: 'toolbar_button_settings',
  356. onClick() {
  357. sendAnalyticsEvent(TOOLBAR_SETTINGS_TOGGLED);
  358. APP.UI.emitEvent(UIEvents.TOGGLE_SETTINGS);
  359. },
  360. sideContainerId: 'settings_container',
  361. tooltipKey: 'toolbar.Settings'
  362. },
  363. /**
  364. * The descriptor of the "Share YouTube video" toolbar button.
  365. */
  366. sharedvideo: {
  367. classNames: [ 'button', 'icon-shared-video' ],
  368. enabled: true,
  369. id: 'toolbar_button_sharedvideo',
  370. onClick() {
  371. sendAnalyticsEvent(TOOLBAR_SHARED_VIDEO_CLICKED);
  372. APP.UI.emitEvent(UIEvents.SHARED_VIDEO_CLICKED);
  373. },
  374. popups: [
  375. {
  376. dataAttr: 'toolbar.sharedVideoMutedPopup',
  377. id: 'sharedVideoMutedPopup'
  378. }
  379. ],
  380. tooltipKey: 'toolbar.sharedvideo'
  381. },
  382. videoquality: {
  383. component: VideoQualityButton
  384. }
  385. };
  386. Object.keys(defaultButtons).forEach(name => {
  387. const button = defaultButtons[name];
  388. if (!button.isDisplayed) {
  389. button.isDisplayed = _isDisplayed;
  390. }
  391. });
  392. return defaultButtons;
  393. }
  394. /**
  395. * The default implementation of the {@code isDisplayed} method of the toolbar
  396. * button definition returned by {@link getDefaultButtons()}.
  397. *
  398. * @returns {boolean} If the user intarface is full i.e. not filmstrip-only,
  399. * then {@code true}; otherwise, {@code false}.
  400. */
  401. function _isDisplayed() {
  402. return !interfaceConfig.filmStripOnly;
  403. }