VideoCapture Module

RhoElements 2.x API

Overview

The VideoCapture Module captures video from the seleted camera saves it as a file on the device.

Syntax

videoCapture (Module) <META> Syntax

<META HTTP-Equiv="VideoCapture" content="[method / parameter]">

<META HTTP-Equiv="VideoCapture" content="VideoSaveEvent:url('[jsFunction | url]')">

VideoCapture JavaScript Object Syntax:
By default the JavaScript Object 'videoCapture' will exist on the current page and can be used to interact directly with the videoCapture.
To Invoke videoCapture methods via JavaScript use the following syntax: videocapture.method();

e.g. videoCapture.start();

To Set videoCapture parameters via JavaScript use the following syntax: videocapture.parameter = 'value'; remembering to enclose your value in quotes where appropriate.

e.g. videoCapture.duration = 'value';

To Set videoCapture return events via JavaScript use the following syntax: videocapture.event = JavaScript Function;

e.g. videoCapture.videoSaveEvent = 'doFunction(%json)';

To set multiple EMML parameters / events on a single line use the following syntax: videocapture.setEMML("[Your EMML Tags]");

e.g. videoCapture.setEMML("duration:value;videoSaveEvent:url('JavaScript:doFunction(%json)');start");

## Methods Items listed in this section indicate methods or, in some cases, indicate parameters which will be retrieved. > NOTE: On Android the operating System presents a preview window with controls (Start, stop and cancel) for recording. The file transfer will happen as specified even if the stop is not sent by this API.
Name Description Default Value
start Starts capturing video until either 'stop' is received, or 'duration' is reached. N/A
stop Stops capturing video and either saves the file locally, or transfers it to a remote server. N/A
cancel Stops capturing video and discards any captured video data. N/A

Parameters

Items listed in this section indicate parameters, or attributes which can be set.

NamePossible ValuesDescriptionDefault Value
duration:[Value] MillisecondsSpecifies the number of milliseconds of video to capture. It is the maximum number of milliseconds of video to capture when the 'start' method is called if not interrupted with the 'stop' method. The duration cannot be set to less than 1000 milliseconds, if a value of less than 1000 milli seconds is specified, the interval will be defaulted to 5000 milli seconds.5000
destination:[Value] Fully qualified URL or file name. Supports HTTP, FTP and File protocols.Sets the destination path and name for the captured video file. See Remarks N/A
username:[Value] StringThe username for the HTTP or FTP server if requiredNo username
password:[Value] StringThe password for the HTTP or FTP server if requiredNo password
name:[Value] String compliant with Windows Naming restrictionsWhen the video capture completes a video file is saved in the root directory of the device (package directory in case of Android). This parameter is used to specify the filename when storing the file locally. VideoCapture

Events

Values are returned to the caller in RhoElements via Events. Most modules contain events and those returned from this module are given below along with the event parameters. Events can cause a navigation to a new URL or a JavaScript function on the page to be invoked. Each event will in most cases have a number of parameters associated with it which will either be strings or JavaScript arrays. Event parameters can be accessed either directly or via JSON objects.


videoSaveEvent

The Video Save Event is called when the captured video has been successfully transfered to the specified destination. When a capture is started with the HTTP protocol, the destination server message is returned. When it is called with the FTP protocol, either 'OK: File Sent', 'OK: File Received' or 'ERROR' is returned. This tag should be used in conjunction with the Start method.

IDNameDescription
1transferResultSuccess or failure of transfer, see note above.

Multi Instance

When multiple RhoElememts applications are running the following considerations should be made: Only the foreground RhoElements application is given access to capture video, when an application is sent to the background any capture that is in progress will be cancelled and it will automatically relinquish control of the video hardware. When brought back to the foreground, an application previously using the video capture will have its previous configuration (eg. name etc.) reapplied to the plugin automatically. Please note that any file transfer that is in progress continues even if the application is sent to the background.

Remarks

Buffer full

Once duration has been reached the video file will be saved or transferred. Calling 'stop' once this has occurred will have no effect.

File Formats

The output file format on Android is MP4 and on Windows is WMV.

File Storage Error

A Video Capture will fail if there is not sufficient space on the device's filesystem to store it.

Setting up a Transfer to a remote HTTP or FTP location

Video Capture is designed to be configured before any transfer is made to a remote location. If the 'Destination' parameter is specified as either HTTP or an FTP location the 'destination' / 'username' / 'password' parameters can not be guaranteed to stay the same after the capture has completed, therefore configure your destination for each capture.

Format of the Destination URL

The protocol, port number, username (optional) and password (optional) are all derived from the URL string and should be specified in the following manner: [protocol]://[username]:[password@]Server[:Port]FileNameAndPath. FTP Example: ftp://admin:root@192.168.1.1:2500/Folder/Cap.mov. HTTP Example: http://admin:root@192.168.1.1:8080/Folder/Upload.aspx. File Example: file://\path\Cap.mov. Remember to also wrap your URL with url('') when being used as part of a meta tag, as shown in the examples above.

Requirements

RhoElements Version2.2 or above
Supported DevicesAll devices.
Minimum RequirementsCamera
PersistenceNot Persistent - Changes to this module will not persist when navigating to a new page.

HTML/JavaScript Examples

The following META Tag example performs a 30 second capture. The resulting video file will be transferred to a server via HTTP and an alert will inform the user whether or not the transfer succeeded.

<META HTTP-Equiv="VideoCapture" Content="duration:30000">
<META HTTP-Equiv="VideoCapture" Content="Destination:url('HTTP://192.168.1.1:80/Uploaded/upload.aspx')">
<META HTTP-Equiv="VideoCapture" Content="VideoSaveEvent:url('javascript:alert('%s');')">
<META HTTP-Equiv="VideoCapture" Content="start">

The following JavaScript will start and stop a video capture respectively when onStart and onStop are called with a 60 second limit:

<script>
   function onStart()
   {
      videoCapture.duration = '60000';
      videoCapture.start();
   }

   function onStop()
   {
      videoCapture.stop();
   }
</script>

The following JavaScript will start a 30 second video capture when onStart is called:

<script>
   function onStart()
   {
      videoCapture.duration = '30000';
      videoCapture.start();
   }
</script>