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

functions.web.ts 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // @ts-expect-error
  2. import keyboardShortcut from '../../../modules/keyboardshortcut/keyboardshortcut';
  3. import { IStateful } from '../base/app/types';
  4. import { createLocalTrack } from '../base/lib-jitsi-meet/functions';
  5. import { toState } from '../base/redux/functions';
  6. import { isPrejoinPageVisible } from '../prejoin/functions';
  7. export * from './functions.any';
  8. /**
  9. * Returns a promise which resolves with a list of objects containing
  10. * all the video jitsiTracks and appropriate errors for the given device ids.
  11. *
  12. * @param {string[]} ids - The list of the camera ids for which to create tracks.
  13. * @param {number} [timeout] - A timeout for the createLocalTrack function call.
  14. *
  15. * @returns {Promise<Object[]>}
  16. */
  17. export function createLocalVideoTracks(ids: string[], timeout?: number) {
  18. return Promise.all(ids.map(deviceId => createLocalTrack('video', deviceId, timeout)
  19. .then((jitsiTrack: any) => {
  20. return {
  21. jitsiTrack,
  22. deviceId
  23. };
  24. })
  25. .catch(() => {
  26. return {
  27. jitsiTrack: null,
  28. deviceId,
  29. error: 'deviceSelection.previewUnavailable'
  30. };
  31. })));
  32. }
  33. /**
  34. * Returns a promise which resolves with a list of objects containing
  35. * the audio track and the corresponding audio device information.
  36. *
  37. * @param {Object[]} devices - A list of microphone devices.
  38. * @param {number} [timeout] - A timeout for the createLocalTrack function call.
  39. * @returns {Promise<{
  40. * deviceId: string,
  41. * hasError: boolean,
  42. * jitsiTrack: Object,
  43. * label: string
  44. * }[]>}
  45. */
  46. export function createLocalAudioTracks(devices: Array<{ deviceId: string; label: string; }>, timeout?: number) {
  47. return Promise.all(
  48. devices.map(async ({ deviceId, label }) => {
  49. let jitsiTrack = null;
  50. let hasError = false;
  51. try {
  52. jitsiTrack = await createLocalTrack('audio', deviceId, timeout);
  53. } catch (err) {
  54. hasError = true;
  55. }
  56. return {
  57. deviceId,
  58. hasError,
  59. jitsiTrack,
  60. label
  61. };
  62. }));
  63. }
  64. /**
  65. * Returns the properties for the "Shortcuts" tab from settings dialog from Redux
  66. * state.
  67. *
  68. * @param {(Function|Object)} stateful -The (whole) redux state, or redux's
  69. * {@code getState} function to be used to retrieve the state.
  70. * @param {boolean} isDisplayedOnWelcomePage - Indicates whether the shortcuts dialog is displayed on the
  71. * welcome page or not.
  72. * @returns {Object} - The properties for the "Shortcuts" tab from settings
  73. * dialog.
  74. */
  75. export function getShortcutsTabProps(stateful: IStateful, isDisplayedOnWelcomePage?: boolean) {
  76. const state = toState(stateful);
  77. return {
  78. displayShortcuts: !isDisplayedOnWelcomePage && !isPrejoinPageVisible(state),
  79. keyboardShortcutsEnabled: keyboardShortcut.getEnabled()
  80. };
  81. }