getUserMedia method Null safety

  1. @SupportedBrowser(SupportedBrowser.CHROME)
Future<MediaStream> getUserMedia(
  1. {dynamic audio = false,
  2. dynamic video = false}

Gets a stream (video and or audio) from the local computer.

Use MediaStream.supported to check if this is supported by the current platform. The arguments audio and video default to false (stream does not use audio or video, respectively).

Simple example usage:

window.navigator.getUserMedia(audio: true, video: true).then((stream) {
  var video = new VideoElement()
    ..autoplay = true
    ..src = Url.createObjectUrlFromStream(stream);

The user can also pass in Maps to the audio or video parameters to specify mandatory and optional constraints for the media stream. Not passing in a map, but passing in true will provide a MediaStream with audio or video capabilities, but without any additional constraints. The particular constraint names for audio and video are still in flux, but as of this writing, here is an example providing more constraints.

    audio: true,
    video: {'mandatory':
               { 'minAspectRatio': 1.333, 'maxAspectRatio': 1.334 },
               [{ 'minFrameRate': 60 },
                { 'maxWidth': 640 }]

See also:


Future<MediaStream> getUserMedia({audio = false, video = false}) {
  var completer = new Completer<MediaStream>();
  var options = {'audio': audio, 'video': video};
      (stream) {
  }, (error) {
  return completer.future;