CameraControl.onRecorderStateChange

This API is available on Firefox OS for privileged or 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

JavaScript
instanceOfCameraControl.<code>onRecorderStateChange = funcRef;</code>

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

JavaScript
// back or front camera
var whichCamera = navigator.mozCameras.getListOfCameras()[0];

var options = {
  mode: 'picture',
  recorderProfile: 'jpg',
  previewSize: {
    width: 352,
    height: 288
  }
};

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(whichCamera, 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

License

© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/cameracontrol/onrecorderstatechange

API B2G Camera camera Firefox OS Graphics JavaScript Property Reference Référence WebAPI