getVideoMedia method

Future<MediaStream> getVideoMedia([
  1. String facing = "user"
])

Implementation

Future<MediaStream> getVideoMedia([String facing = "user"]) async {
  currentFacingMode = facing;
  if (currentVideoStream != null) {
    final stream = currentVideoStream;
    if (stream != null) {
      stream.getVideoTracks().forEach((track) {
        track.stop();
      });
    }
    await currentVideoStream?.dispose();
    currentVideoStream = null;
  }
  final newStream = await navigator.mediaDevices.getUserMedia(
      {'video': {"facingMode":facing,
                  "width"  : CAMERA_RESOLUTION_WIDTH,
                  "height" : CAMERA_RESOLUTION_HEIGHT,
                  // "width" : {"min" : CAMERA_RESOLUTION_MIN_WIDTH, "ideal" : CAMERA_RESOLUTION_WIDTH },
                  // "height": {"min" : CAMERA_RESOLUTION_MIN_HEIGHT, "ideal" : CAMERA_RESOLUTION_HEIGHT },
                }
      });
  currentVideoStream = newStream;
  return newStream;
}