MediaDevices
The corresponding JS API docs is here MediaDevices.
#
UsageMediaDevices mediaDevices = await navigator.mediaDevices;
MediaStream stream = await mediaDevices.getUserMedia({ 'audio': true, 'video': true,});
MediaStream displayStream = await mediaDevices.getDisplayMedia({ 'video': true, 'audio': true,});
List<MediaDeviceInfo> devices = await mediaDevices.enumerateDevices();
#
MethodsgetUserMedia
: Returns a Promise that resolves to aMediaStream
object. TheMediaStream
object represents a stream of media content, typically (but not necessarily) including both audio and video.
MediaStream stream = await mediaDevices.getUserMedia({ 'audio': true, 'video': true,});
getDisplayMedia
: Returns a Promise that resolves to aMediaStream
object. TheMediaStream
object represents a stream of media content, typically (but not necessarily) including both audio and video.
MediaStream stream = await mediaDevices.getDisplayMedia({ 'video': true, 'audio': true,});
enumerateDevices
: Returns a Promise that resolves to an array ofMediaDeviceInfo
objects, each of which represents a media input or output device.
List<MediaDeviceInfo> devices = await mediaDevices.enumerateDevices();
getSupportedConstraints
: Returns a dictionary object that specifies the media constraints supported by the user agent. only support for web platform.selectAudioOutput
: select audio output device. support platforms: macOS/Windows/Linux/Web.
#
Event CallbacksonDeviceChange
: Theondevicechange
event handler for theMediaDevices
interface. It is called when a media input or output device is attached or removed.