Warning Older Docs! - You are viewing documentation for a previous released version of RhoMobile Suite.

VideoCapture Module

The VideoCapture Module captures video files from the default camera 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)';

For more details on the event syntax and parameters see the Retrieval Events page.
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");
VideoCapture Ruby Object Syntax:
By default the Ruby Object 'VideoCapture' will exist on the current page and can be used to interact directly with the VideoCapture. All Methods, Parameters and Events are the same as JavaScript, however, notice 'VideoCapture' needs to start with an uppercase letter. Another difference in Ruby is that methods do not end in '()'
To Invoke VideoCapture methods via Ruby use the following syntax: VideoCapture.method()

e.g. VideoCapture.start
To Set VideoCapture parameters via Ruby 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 Ruby use the following syntax: VideoCapture.event = url_for(:action => :event_callback)

e.g. VideoCapture.videoSaveEvent = url_for(:action => :videocapture_event_callback)

For more details on the event syntax and parameters see the Retrieval Events page.

To access the event parameters in a Ruby callback function, you reference the @params object within the callback function. This object is simply a ruby hash {"parameter1 name" => "parameter1 value", "parameter2 name" => "parameter2 value", ...}

Methods

Items listed in this section indicate methods or, in some cases, indicate parameters which will be retrieved.

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.

Name Possible Values Description Default Value
duration:[Value] Milliseconds Specifies 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] String The username for the HTTP or FTP server if required No username
password:[Value] String The password for the HTTP or FTP server if required No password
name:[Value] String compliant with Windows Naming restrictions When 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.

ID Name Description
1 transferResult Success 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 Version 2.2 or above
Supported Devices All devices.
Minimum Requirements Camera
Persistence Not 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>
Back to Top