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.

actions.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import JitsiMeetJS from '../lib-jitsi-meet';
  2. import {
  3. SET_AUDIO_INPUT_DEVICE,
  4. SET_VIDEO_INPUT_DEVICE,
  5. UPDATE_DEVICE_LIST
  6. } from './actionTypes';
  7. /**
  8. * Queries for connected A/V input and output devices and updates the redux
  9. * state of known devices.
  10. *
  11. * @returns {Function}
  12. */
  13. export function getAvailableDevices() {
  14. return dispatch => new Promise(resolve => {
  15. const { mediaDevices } = JitsiMeetJS;
  16. if (mediaDevices.isDeviceListAvailable()
  17. && mediaDevices.isDeviceChangeAvailable()) {
  18. mediaDevices.enumerateDevices(devices => {
  19. dispatch(updateDeviceList(devices));
  20. resolve(devices);
  21. });
  22. } else {
  23. resolve([]);
  24. }
  25. });
  26. }
  27. /**
  28. * Signals to update the currently used audio input device.
  29. *
  30. * @param {string} deviceId - The id of the new audio input device.
  31. * @returns {{
  32. * type: SET_AUDIO_INPUT_DEVICE,
  33. * deviceId: string
  34. * }}
  35. */
  36. export function setAudioInputDevice(deviceId) {
  37. return {
  38. type: SET_AUDIO_INPUT_DEVICE,
  39. deviceId
  40. };
  41. }
  42. /**
  43. * Signals to update the currently used video input device.
  44. *
  45. * @param {string} deviceId - The id of the new video input device.
  46. * @returns {{
  47. * type: SET_VIDEO_INPUT_DEVICE,
  48. * deviceId: string
  49. * }}
  50. */
  51. export function setVideoInputDevice(deviceId) {
  52. return {
  53. type: SET_VIDEO_INPUT_DEVICE,
  54. deviceId
  55. };
  56. }
  57. /**
  58. * Signals to update the list of known audio and video devices.
  59. *
  60. * @param {Array<MediaDeviceInfo>} devices - All known available audio input,
  61. * audio output, and video input devices.
  62. * @returns {{
  63. * type: UPDATE_DEVICE_LIST,
  64. * devices: Array<MediaDeviceInfo>
  65. * }}
  66. */
  67. export function updateDeviceList(devices) {
  68. return {
  69. type: UPDATE_DEVICE_LIST,
  70. devices
  71. };
  72. }