The Recorder class lets you record stand-alone archives. Use the Recorder class to record
a video outside of the context of an OpenTok session. (In contrast, the Session.startRecording()
and Stream.startRecording() methods record streams in an OpenTok session.)
The recorder includes the following user interface controls:
recordingStarted event.recordingStopped event.playbackStarted event. There is also
a Rewind button (to rewind the playback to the beginning).archiveSaved event when the archive is saved. (Note: you
can choose to hide this button by setting the showSaveButton property of the
properties parameter of the displayRecorder() method to
false.) You can also save a recording by calling the saveArchive()
method of the Recorder object.The recording is saved when the user clicks the Save button or when you call the
saveArchive() method of the Recorder object.
The Recorder object dispatches a archiveSaved event when the archive
is saved on the OpenTok servers. This event is defined by the ArchiveEvent class.
The value of the archiveId property is the unique archive ID.
Important: You will want to store the archiveID property of the
archiveCreated event for future playback of the archive. For example,
you may want to store this in a server-side database table.
Videos created with the Recorder are limited to 90 minutes in length.
For an example of using the Recorder class, see the example in the RecorderManager documentation.
See
Recorder objects have the following methods.
| Method | Description |
|---|---|
| addEventListener(eventType:String, listener:Function) | Registers a method as an event listener for a specific event. |
| getImgData():String | Returns a base-64-encoded string of PNG data representing the Recorder video. |
| getStyle():Object | Gets an object that has properties that define the current appearance of user interface controls of the Subscriber. |
| saveArchive() | Saves the recorded archive to the OpenTok servers. |
| removeEventListener(eventType:String, listener:Function) | Removes an event listener for a specific event. |
| setStyle(style:Object, [value:Object]):Recorder | Sets properties that define the appearance of some user interface controls of the Recorder. |
| setTitle(title:String) | Sets the title of the next archive to be recorded. |
| startPlaying() | Starts playing the archive. |
| startRecording() | Starts recording the archive. |
| stopPlaying() | Stops playing the archive. |
| stopRecording() | Stops recording the archive. |
Registers a method as an event listener for a specific event.
Parameters
type (String) This string identifying the type of event. See Recorder events.
listener (Function) The function to be invoked when the Player object dispatches the event.
Returns a base-64-encoded string of PNG data representing the Recorder video. Returns an empty string if there is no video.
You can use the string as the value for a data URL scheme passed to the src parameter of an image file, as in the following:
var imgData = recorder.getImgData();
var img = document.createElement("img");
img.setAttribute("src", "data:image/png;base64," + imgData);
document.body.appendChild(img); // Or append as a child of another DOM element
You can store this image data on your server so that you can later provide it to a page as a preview of an archive video.
Returns an object that has the properties that define the current user interface controls of the Recorder.
You can modify the properties of this object and pass the object to the setStyle() method of the
Recorder object. (See the documentation for setStyle() to see the styles that define
this object.)
Removes an event listener for a specific event.
Parameters
type (String) The string identifying the type of event.
listener (Function) The event listener function to remove.
The TB object throws an exception if the listener name is invalid.
See
Saves the recorded archive to the OpenTok server.
A recording is saved when the user clicks the Save button or when you call the
saveArchive() method of the Recorder object.
The Recorder object dispatches a archiveSaved event when the archive
is created on the OpenTok servers. This event is defined by the ArchiveEvent class.
The value of the archiveId property is the unique archive ID.
Important: You will want to store the archiveID property of the
archiveSaved event for future playback of the archive. For example,
you may want to store this in a server-side database table.
Sets properties that define the appearance of some user interface controls of the Recorder.
You can either pass one parameter or two parameters to this method.
If you pass one parameter, style, it is an object that has the following properties
that define the style:
buttonDisplayMode (String) How to display the microphone controls and settings buttons.
Possible values are: "auto" (buttons are displayed when the stream is first displayed
and when the user mouses over the display), "off" (buttons are not displayed),
and "on" (buttons are displayed). The showMicButton and
showSettingsButton properties define whether each individual control is displayed.showControlBar (Boolean) Whether to display the control bar.
If you do not specify a value, the Recorder displays the control bar (by default). The control bar includes the following
buttons: Record, Record Stop, Re-record, Play, Save, and Play Stop. (You can create your own user interface that calls
methods of the Recorder object that control these actions.) You can set other properties of the style property
to control the display of individual buttons.showMicButton (Boolean) Whether to display the microphone controls.showRecordButton (Boolean) Whether to display a Record button.
If you do not specify a value, the Recorder displays the Record button (by default). (You can start a recording
by calling the startRecording() method of the Recorder object.)showRecordCounter (Boolean) Whether to display the recording time indicator. This parameter is optional.
If you do not specify a value, the Recorder displays the recording time indicator (by default).showRecordStopButton (Boolean) Whether to display a Stop Recording button.
If you do not specify a value, the Recorder displays the Stop Recording button (by default). (You can stop a recording
by calling the stopRecording() method of the Recorder object.)showReRecordButton (Boolean) Whether to display a Re-record button.
If you do not specify a value, the Recorder displays the Re-record button (by default).showPlayButton (Boolean) Whether to display a Play button.
If you do not specify a value, the Recorder displays the Play button (by default).showPlayCounter (Boolean) Whether to display the playback preview time indicator.
If you do not specify a value, the Recorder displays the playback preview time indicator (by default).showPlayStopButton (Boolean) Whether to display a Stop Recording button.
If you do not specify a value, the Recorder displays the Stop Playing button (by default).showSaveButton (Boolean) Whether to display the Save button. (Note: in addition to using
the Save button, you can save an archive by calling the saveArchive() method.)showSettingsButton (Boolean) Whether to display the settings buttons.For example, the following code passes one parameter to the method:
var newStyle = {
buttonDisplayMode: "auto",
showMicButton: true,
showSaveButton: true,
showSettingsButton: false,
}
myRecorder.setStyle(newStyle);
If you pass two parameters, style and value, they are key-value pair that
define one property of the display style. For example, the following code passes two parameter values
to each call of the method:
myRecorder.setStyle("buttonDisplayMode", "auto");
myRecorder.setStyle("showSaveButton", true);
You can set the initial settings when you call the RecorderManager.displayRecorder()
method. Pass a style property as part of of the properties parameter
of the method.
Parameters
style (Object) Either an object containing properties that define the style, or a String defining this single style property to set.
value (String) The value to set for the style
passed in. Pass a value for this parameter only if the value of the style parameter is a String.
Returns
The Recorder object.
Event
The TB object dispatches an exception event if you pass in an invalid style to the method.
The code property of the ExceptionEvent object is set to 1011.
See
Sets the title of the next archive to be recorded. Call this method before the recording starts.
An Archive object includes a title property.
You can set the title of the initial recording by setting the initialArchiveTitle
property of the properties parameter of the RecorderManager.displayRecorder() method.
Parameters
title (String) The title for the archive.
Starts playing the archive. Calling this method has no effect if the archive has not been recorded or if the archive is currently being played back.
You can use this method in place of having the user click the Play button.
You can hide the Play button by setting the showPlayButton property of the
style property of the properties parameter when you call the
RecorderManager.displayRecorder() method.
Starts recording the archive.
You can use this method in place of having the user click the Record button.
You can hide the Record button by setting the showRecordButton property of the
style property of the properties parameter when you call the
RecorderManager.displayRecorder() method.
If you have started recording an archive and have not yet saved it, calling the startRecording()
method starts recording a new archive (and deletes the previous recording). For example, while you are playing back
an unsaved recording, you can call the startRecording() to restart the recording. However, calling the
startRecording() method while a recording is in progress has no effect.
Stops playing the archive. Calling this method has no effect if the archive is not being played back.
You can use this method in place of having the user click the Stop button.
You can hide the Stop button by setting the showPlayStopButton property of the
style property of the properties parameter when you call the
RecorderManager.displayRecorder() method.
Stop recording the archive.
You can use this method in place of having the user click the Record button.
You can hide the Record button by setting the showRecordStopButton property of the
style property of the properties parameter when you call the
RecorderManager.displayRecorder() method.
A Recorder object can dispatch the following events:
| Event type | Event class | Description |
|---|---|---|
"accessAllowed" |
Event | The user has clicked the Allow button in the Flash Player Settings dialog box, granting the app access to the camera and microphone. |
"accessDenied" |
Event | The user has clicked the Deny button in the Flash Player Settings dialog box, preventing the app from having access to the camera and microphone. |
"accessDialogClosed" |
Event | The Flash Player Settings dialog box closed. (This is the dialog box in which the user can grant the app access to the camera and microphone.) |
"accessDialogOpened" |
Event | The Flash Player Settings dialog box has opened. (This is the dialog box in which the user can grant the app access to the camera and microphone.) |
"archiveSaved" |
ArchiveEvent | The archive was saved to the OpenTok server. |
"resize" |
ResizeEvent | The Flash Player settings dialog box is being displayed, and the HTML element containing the video must be resized to fit the entire dialog box. The Recorder object dispatches this event only if the HTML element is smaller than 215 x 138 pixels. |
"playbackStarted" |
Event | Playback of the archive started. |
"playbackStopped" |
Event | Playback of the archive stopped. |
"recordingStarted" |
Event | The user has started recording an archive. |
"recordingStopped" |
Event | The user has stopped recording an archive. |