Media Capture
enyo.MediaCapture is a non-control component that's used to manage the capturing of media in webOS. It is found under framework/lib/mediacapture in the Enyo source tree. To use the Media Capture API in an application, add the following line to the app's depend.js file:
"$enyo-lib/mediacapture/"
Published Properties
| Name | Default | Description |
|---|---|---|
| lastImagePath | "" | Path of the last captured image |
| lastVideoPath | "" | Path of the last captured video |
| lastAudioPath | "" | Path of the last captured audio |
Public Events
The following events are sent back to the client to signal the start or completion of an action, or some other change in state.
- onAudioCaptureComplete
- onAudioCaptureStart
- onAutoFocusComplete
- onDuration
- onDurationChange
- onElapsedTime
- onError
- onImageCaptureComplete
- onImageCaptureStart
- onInitialized
- onLoaded
- onVideoCaptureComplete
- onVideoCaptureStart
- onVuData
Public Methods
initialize(videoObjectFromClient)
Fires the call to initialize an instance of MediaServer.
videoObjectFromClient is an optional HTML5 video object used as the preview for the byte stream from the media server.
load(mode, format)
Loads the media capture device.
-
modeis the desired capture mode. -
formatis the format desired for the specified capture mode.
Both mode and format come from the (required) property bag.
startImageCapture(filePath, imageCaptureOptions)
Starts an image capture.
-
filePathis the name of the captured file, or an empty string by default. -
imageCaptureOptionsis a JSON-formatted object containing the desired image capture format settings, e.g.,{ "bitrate": 0, "samplerate": 0, "width": 2032, "height": 1520, "mimetype": "image/jpeg", "codecs":"jpeg" }
startAudioCapture(filePath, audioCaptureOptions)
Starts an audio capture.
-
filePathis the name of the captured file, or an empty string by default. -
audioCaptureOptionsis a JSON-formatted object containing the desired audio capture format settings, e.g.,{ "bitrate":128000, "samplerate":8000, "width":0, "height":0, "mimetype":"audio/vnd.wave", "codecs":"1" }
stopAudioCapture()
Stops the current audio capture.
startVideoCapture(filePath, videoCaptureOptions)
Starts a video capture.
-
filePathis the name of the captured file, or an empty string by default. -
videoCaptureOptionsis a JSON-formatted object containing the desired video capture format settings, e.g.,{ "bitrate": 1100000, "samplerate": 44100, "width": 1280, "height": 720, "mimetype": "video/mp4", "codecs": "mp4v.20,mp4a.40" }
stopVideoCapture()
Stops the current video capture.
unload()
Unloads the currently-loaded device.
updateAutoFocus(autoFocusSettings)
Resets the current auto focus with the settings specified in the passed-in object.
autoFocusSettings is a JSON-formatted object with the following fields:
- centerX
- centerY
- width
- height
- virtualWidth
- virtualHeight
- flash
- type