• Public
  • Public/Protected
  • All

Interface DeviceController

DeviceController keeps track of the devices being used for audio input (e.g. microphone), video input (e.g. camera), audio output (e.g. speakers). The list functions return MediaDeviceInfo objects. Once any list function is called, changes in device availability are broadcast to any registered DeviceChangeObserver.

Calling a choose function will request permission for the device indicated by the device id or track constraint. Supply null to get the default device. Make sure to choose the audio device before joining the session (even if it is the default device) so that you can offer the user options if the device cannot be selected before a connection is made.

Note that in certain situations such as private tabs, the browser may initially decline to provide device labels for when enumerating devices. If this is the case, the internal device label trigger function is called to try to coax the browser in to providing the labels. The default behavior of the function is to make a microphone and camera access request which, if successful, will unlock the labels. You may want to override this behavior to provide a custom UX such as a prompt explaining why microphone and camera access is being asked for by supplying your own function to setDeviceLabelTrigger(). To disable the device label trigger, supply a function that returns a rejected promise instead. For reference, the default implementation calls getUserMedia for audio and video and returns the promise to the stream so that the stream can be cleaned up once the labels are detected.

(): Promise<MediaStream> => {
  return navigator.mediaDevices.getUserMedia({ audio: true, video: true });

When you are done using a DeviceController, you should perform some cleanup steps in order to avoid memory leaks:

  1. Deselect any audio input or output devices by calling DeviceController.chooseAudioInputDevice and DeviceController.chooseAudioOutputDevice with null.
  2. Remove any device change observers that you registered by using DeviceController.removeDeviceChangeObserver.
  3. Drop your reference to the controller to allow it to be garbage collected.






  • Selects an audio input device to use. The constraint may be a device id, MediaTrackConstraint, MediaStream (containing audio track), or null to indicate no device. It may also be an AudioTransformDevice to customize the constraints used or to apply Web Audio transforms.

    The promise will resolve indicating success or it will throw an appropriate error indicating the failure.


    Returns Promise<void>


  • chooseAudioOutputDevice(deviceId: string | null): Promise<void>


  • Selects a video input device to use. The constraint may be a device id, MediaTrackConstraint, MediaStream (containing video track), or null to indicate no device. The promise will resolve indicating success or it will throw an appropriate error indicating the failure.


    Returns Promise<void>


  • chooseVideoInputQuality(width: number, height: number, frameRate: number, maxBandwidthKbps: number): void
  • Sets the video input quality parameters to request when enabling video. These settings take effect the next time a video input device is chosen. The default is 960x540 @ 15 fps with a max bandwidth of 1400 kbps.


    • width: number
    • height: number
    • frameRate: number
    • maxBandwidthKbps: number

    Returns void




  • listAudioInputDevices(): Promise<MediaDeviceInfo[]>


  • listAudioOutputDevices(): Promise<MediaDeviceInfo[]>


  • listVideoInputDevices(): Promise<MediaDeviceInfo[]>


  • mixIntoAudioInput(stream: MediaStream): MediaStreamAudioSourceNode



  • setDeviceLabelTrigger(trigger: () => Promise<MediaStream>): void
  • Sets the device label trigger to use in the case where media device labels are not present due to privacy restrictions in the browser. See above for an explanation of how this works.


    • trigger: () => Promise<MediaStream>
        • (): Promise<MediaStream>
        • Returns Promise<MediaStream>

    Returns void


  • startVideoPreviewForVideoInput(element: HTMLVideoElement): void
  • Starts a video preview of the currently selected video and binds it a video element to be displayed before a meeting begins. Make sure to call stopVideoPreviewForVideoInput when the preview is no longer necessary so that the stream can be released and turn off the camera if it is not being used anymore.


    • element: HTMLVideoElement

    Returns void


  • stopVideoPreviewForVideoInput(element: HTMLVideoElement): void

Generated using TypeDoc