-
Notifications
You must be signed in to change notification settings - Fork 0
RTCMediaDevice
getAudioInputDevices(): Promise<MediaDevice[]>
getAudioOutputDevices(): Promise<MediaDevice[]>
getVideoInputDevices(): Promise<MediaDevice[]>
getMediaStream(deviceId: string): Promise<MediaStream>
getAudioMediaStream(deviceId: string | null): Promise<MediaStream>
getVideoMediaStream(deviceId: string | null, cameraOrientation?: CameraOrientation): Promise<MediaStream>
closeMediaStream(mediaStream: MediaStream)
Returns an array of MediaDevice
objects representing the available audio input devices.
none
-
Promise<MediaDevice[]>
- Promise that resolves to an array ofMediaDevice
objects.
RTCMediaDevice.getAudioInputDevices().then(
mediaDevices => {
console.log(`Available audio input devices: ${mediaDevices.map(device => device.label).join(', ')}`)
}
);
Returns an array of MediaDevice
objects representing the available audio output devices.
none
-
Promise<MediaDevice[]>
- Promise that resolves to an array ofMediaDevice
objects.
RTCMediaDevice.getAudioOutputDevices().then(
mediaDevices => {
console.log(`Available audio ouput devices: ${mediaDevices.map(device => device.label).join(', ')}`)
}
);
Returns an array of MediaDevice
objects representing the available video input devices.
none
-
Promise<MediaDevice[]>
- Promise that resolves to an array ofMediaDevice
objects.
RTCMediaDevice.getVideoInputDevices().then(
mediaDevices => {
console.log(`Available video input devices: ${mediaDevices.map(device => device.label).join(', ')}`)
}
);
Returns a MediaStream
object that represents a stream
of media content from a device associated with a given deviceId
.
-
deviceId
:string
- Audio or video input device identifier.
-
Promise<MediaStream>
- Promise that resolves to aMediaStream
object.
RTCMediaDevice.getAudioInputDevices().then(mediaDevices => {
let deviceId = mediaDevices[0].deviceId;
RTCMediaDevice.getMediaStream(deviceId)
.then(stream => $('#my-audio').srcObject = stream);
});
Returns a MediaStream
object that represents a stream
of an audio media content from a device associated with a given deviceId
.
-
deviceId
:string
- Audio input device identifier.
-
Promise<MediaStream>
- Promise that resolves to aMediaStream
object.
RTCMediaDevice.getAudioMediaStream(null)
.then(stream => $('#my-audio').srcObject = stream);
Returns a MediaStream
object that represents a stream
of a video media content from a device associated with a given deviceId
.
-
deviceId
:string
- Video input device identifier. -
cameraOrientation
:CameraOrientation
- Optional enum value representing camera facing mode of the preview video. Default value isFRONT
.
-
Promise<MediaStream>
- Promise that resolves to aMediaStream
object.
RTCMediaDevice.getVideoMediaStream(null)
.then(stream => $('#my-video').srcObject = stream);
Closes a media stream. This should be done whenever the stream is not needed anymore or an interaction with it is over.
-
mediaStream
:MediaStream
- A media stream that you want to close.
N/A
const stream = $('#my-video').srcObject;
RTCMediaDevice.closeMediaStream(stream);
$('#my-video').srcObject = null;