CameraControl.onRecorderStateChange

« DOM Reference

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.

This API is available on Firefox OS for certified applications only.

Summary

The onRecorderStateChange property is used to set an event handler to listen to the recorder state change. This can happen either because the recording process encountered an error, or because one of the recording limits set with CameraControl.startRecording() was reached.

Syntax

instanceOfCameraControl.onRecorderStateChange = funcRef;

Where funcRef is a function to be called when the recorder changes states.

This function takes one parameter, which is one of the following strings:

  • FileSizeLimitReached
  • VideoLengthLimitReached
  • MediaRecorderFailed
  • MediaServerFailed
  • TrackCompleted
  • TrackFailed

Example

var options = {
  camera: navigator.mozCameras.getListOfCameras()[0]
};
 
function onSuccess( camera ) {
  var outputString = {
    FileSizeLimitReached   : "The file size has reached its limit",
    VideoLengthLimitReached: "The time limit for the video has been reached",
    MediaRecorderFailed    : "The recorder encountered an error",
    MediaServerFailed      : "The media source encountered an error",
    TrackCompleted         : "The recording ended nicely",
    TrackFailed            : "Something went wrong"
  };

  camera.onRecorderStateChange = function (value) {
    console.log(outputString[value]);
  }
};

navigator.mozCameras.getCamera(options, onSuccess)

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, kscarfone, ajaybhat, Jeremie
Last updated by: ajaybhat,