mozilla
Your Search Results

    CameraControl.getPreviewStreamVideoMode()

    Non-standard
    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.

    Summary

    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.

    Syntax

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

    Parameters

    options
    An object defining the video mode to use. This object must be equal to one of the objects available through CameraCapabilities.videoSizes
    onsuccess
    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.

    Example

    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;
      display.play();
    }
    
    function onAccessCamera( camera ) {
      var size = camera.capabilities.videoSizes[0];
    
      camera.getPreviewStreamVideoMode(size, onStreamReady);
    };
    
    navigator.mozCameras.getCamera(options, onAccessCamera)
    

    Specification

    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,