Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

JitsiMediaDevices.js 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. var EventEmitter = require("events");
  2. var RTCEvents = require('./service/RTC/RTCEvents');
  3. var RTC = require("./modules/RTC/RTC");
  4. var JitsiMediaDevicesEvents = require('./JitsiMediaDevicesEvents');
  5. var eventEmitter = new EventEmitter();
  6. RTC.addListener(RTCEvents.DEVICE_LIST_CHANGED,
  7. function (devices) {
  8. eventEmitter.emit(JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED, devices);
  9. });
  10. var JitsiMediaDevices = {
  11. /**
  12. * Executes callback with list of media devices connected.
  13. * @param {function} callback
  14. */
  15. enumerateDevices: function (callback) {
  16. RTC.enumerateDevices(callback);
  17. },
  18. /**
  19. * Checks if its possible to enumerate available cameras/micropones.
  20. * @returns {boolean} true if available, false otherwise.
  21. */
  22. isDeviceListAvailable: function () {
  23. return RTC.isDeviceListAvailable();
  24. },
  25. /**
  26. * Returns true if changing the input (camera / microphone) or output
  27. * (audio) device is supported and false if not.
  28. * @params {string} [deviceType] - type of device to change. Default is
  29. * undefined or 'input', 'output' - for audio output device change.
  30. * @returns {boolean} true if available, false otherwise.
  31. */
  32. isDeviceChangeAvailable: function (deviceType) {
  33. return RTC.isDeviceChangeAvailable(deviceType);
  34. },
  35. /**
  36. * Returns currently used audio output device id, '' stands for default
  37. * device
  38. * @returns {string}
  39. */
  40. getAudioOutputDevice: function () {
  41. return RTC.getAudioOutputDevice();
  42. },
  43. /**
  44. * Sets current audio output device.
  45. * @param {string} deviceId - id of 'audiooutput' device from
  46. * navigator.mediaDevices.enumerateDevices(), '' is for default device
  47. * @returns {Promise} - resolves when audio output is changed, is rejected
  48. * otherwise
  49. */
  50. setAudioOutputDevice: function (deviceId) {
  51. return RTC.setAudioOutputDevice(deviceId);
  52. },
  53. /**
  54. * Adds an event handler.
  55. * @param {string} event - event name
  56. * @param {function} handler - event handler
  57. */
  58. addEventListener: function (event, handler) {
  59. eventEmitter.addListener(event, handler);
  60. },
  61. /**
  62. * Removes event handler.
  63. * @param {string} event - event name
  64. * @param {function} handler - event handler
  65. */
  66. removeEventListener: function (event, handler) {
  67. eventEmitter.removeListener(event, handler);
  68. }
  69. };
  70. module.exports = JitsiMediaDevices;