We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE

CameraControl.getPreviewStreamVideoMode Redirect 1

This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.


This method is used to configure and access a MediaStream from the camera. You use the resulting MediaStream object to record video.

Note: You must use this method to get a MediaStream suitable for recording video. If you want to capture still images, you need to call CameraControl.getPreviewStream() instead.


CameraControl.getPreviewStreamVideoMode(options, onsuccess[, onerror]);


An object defining the video mode to use. This object must be equal to one of the objects available through CameraCapabilities.videoSizes
A callback function that will accept one parameter. This parameter is a MediaStream object.
onerror Optional
A callback function that accepts an error string as parameter. This is called if an error occurs while attempting to get the MediaStream.


This example gets the preview stream and starts playing it.

var display = document.getElementsByTagName('video')[0];
var options = {
  camera: navigator.mozCameras.getListOfCameras()[0]

function onStreamReady( stream ) {
  display.mozSrcObject = stream;

function onAccessCamera( camera ) {
  var size = camera.capabilities.videoSizes[0];

  camera.getPreviewStreamVideoMode(size, onStreamReady);

navigator.mozCameras.getCamera(options, onAccessCamera)


Not part of any specification; however, this API should be removed when the WebRTC Capture and Stream API has been implemented.

See also

Document Tags and Contributors

 Last updated by: Sheppy,