Your Search Results


    This feature is not on a current W3C standards track, but it is supported on the Firefox OS platform. Although implementations may change in the future and it is not supported widely across browsers, it is suitable for use in code dedicated to Firefox OS apps.


    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

    Contributors to this page: Sheppy, teoli, kscarfone, ajaybhat, Jeremie
    Last updated by: teoli,