Have you explored the newest version of the OpenTok platform? Check out OpenTok 2.0, built on top of WebRTC. Learn more

Support for OpenTok 1.0 Archiving is no longer being offered, but the API remains accessible. We now offer a new and improved Archiving support for OpenTok 2.0. Learn more

RecorderManager class

Manages recording and playing back of stand-alone archives. A stand-alone archive is a video that is recorded independent of an OpenTok session. (In contrast, the Session.startRecording() and Stream.startRecording() methods record streams in an OpenTok session.)

Use the RecorderManager class to create Recorder and Player objects. Use the Recorder class to record a video archive. Once you have recorded and saved an archive, you can play the archive back in a stand-alone player, using the Player class. Or you can play it back in an OpenTok session (using the Session.loadArchive() and Archive.startPlayback() methods). If you play an archive back in an OpenTok session, all clients connected to the session can view the archive playback.

Note: The OpenTok archiving API also lets your record archives of audio-video streams in an OpenTok session, as well as stand-alone archives. See the documentation for the Session.createArchive() method.

See

Archive.startPlayback()

Player

Recorder

Session.loadArchive()

TB.initRecorderManager()

RecorderManager methods

The RecorderManager object has the following methods.

Method Description
displayPlayer(archiveId:String, token:String [, replaceElementId:String, properties:Object]):Player Displays a player (for playing back individual archives).
displayRecorder(token:String [, replaceElementId:String, properties:Object]):Recorder Displays a recorder (for recording individual archives).
removePlayer(player:Player) Removes the specified player from the HTML DOM.
removeRecorder(recorder:Recorder) Removes the specified recorder from the HTML DOM.

displayPlayer(archiveId:String, token:String [, replacementElementId:String, properties:Object]):Player

Displays a player for playing back stand-alone archives.

The method returns a Player object. The player is displayed in the HTML page.

Parameters

archiveId (String) — The archive ID of the archive that you initially want to load in the Player.

token (String) — An OpenTok token string. The token must have been assigned the role of moderator. Generate OpenTok tokens using the createToken() method of the OpenTok server-side library or the Dashboard page.

replacementElementId (String) — The ID of the DOM element that the recorder will replace. This value is optional. If you do not specify a replacement element ID, the method appends the recorder as a child of the body element, centered in the page.

properties (Object) — This object can have the following properties (each of which is optional):

  • autoPlay (Boolean) — Whether to automatically play archives when they are loaded. The default value is false.
  • height (Number) — The height of the player. The default height is 271 pixels.
  • style (Object) — An object containing properties that define the appearance of some user interface controls of the Recorder. The style object includes the following properties:

    • buttonDisplayMode (String) — How to display the speaker controls. Possible values are: "auto" (controls are displayed when the stream is first displayed and when the user mouses over the display), "off" (controls are not displayed), and "on" (controls are displayed).
    • showControlBar (Boolean) — Whether to display the control bar. This parameter is optional. If you do not specify a value, the Player displays the control bar (by default). The control bar includes the Pause button, the Play button, and the playback time indicator. (You can create your own user interface that calls methods of the Player object that control these actions.) You can set other properties of the style property to control the display of the Pause button, and the Play button.
    • showPauseButton (Boolean) — Whether to display a Pause button. This parameter is optional. If you do not specify a value, the Player displays the Pause button (by default).
    • showPlayButton (Boolean) — Whether to display a Play button. This parameter is optional. If you do not specify a value, the Player displays the Play button (by default).
    • showPlayCounter (Boolean) — Whether to display the playback time indicator. This parameter is optional. If you do not specify a value, the Player displays the playback time indicator (by default).
    • showPreviewTime (Boolean) — Whether to display the video duration in the preview screen of the Player. This parameter is optional. If you do not specify a value, the Player displays the video duration in the preview screen (by default).
  • width (Number) — The width of the player. The default width is 320 pixels.
  • wmode (String) — Set this property to set the transparency of the SWF object used to display the player. Possible values match the wmode values for the object and embed tags for a SWF file: "opaque", "transparent" (the default), or "window". (For more information, see Flash OBJECT and EMBED tag attributes (at adobe.com).

To remove the player from the page, call the removePlayer() method.

Returns

Player — The Player object.

displayRecorder(token:String [, replacementElementId:String, properties:Object]):Recorder

Displays a recorder for recording an archive.

The displayRecorder() method returns a Recorder object. The recorder is displayed in the HTML page.

Parameters

token (String) — An OpenTok token string. The token must have been assigned the role of moderator. Generate OpenTok tokens using the createToken() method of the OpenTok server-side library or the Dashboard page.

replacementElementId (String) — The ID of the DOM element that the recorder will replace. This value is optional. If you do not specify a replacement element ID, the method appends the recorder as a child of the body element, centered in the page.

properties (Object) — This object can have the following properties (each of which is optional):

  • height (Number) — The height of the recorder. The default height is 271 pixels with the control bar displayed or 240 pixels without the control bar displayed.
  • initialArchiveTitle (Boolean) — The title of the first archive recorded. You can set the title of subsequent archives by calling the setTitle() method of the Recorder object. (Call this method before the recording starts.) An Archive object includes a title property.
  • rememberDeviceAccess (Boolean) — Whether to display a "Remember" option in the Flash Player Settings dialog box. The Flash Player Settings dialog box lets the user grant access to the camera and microphone for a website. When you set this property to true, the user's selection is remembered in subsequent uses of the OpenTok API.
  • style (Object) — An object containing properties that define the appearance of some user interface controls of the Recorder. The style object includes the following properties:

    • buttonDisplayMode (String) — How to display the microphone controls and settings button. Possible values are: "auto" (controls are displayed when the video is first displayed and when the user mouses over the display), "off" (controls are not displayed), and "on" (controls are always displayed). The showMicButton and showSettingsButton properties define whether each individual control is displayed.
    • showControlBar (Boolean) — Whether to display the control bar. This parameter is optional. 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. This parameter is optional. 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. This parameter is optional. 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. This parameter is optional. If you do not specify a value, the Recorder displays the Re-record button (by default).
    • showPlayButton (Boolean) — Whether to display a Play button. This parameter is optional. 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. This parameter is optional. 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. This parameter is optional. If you do not specify a value, the Recorder displays the Stop Playing button (by default).
    • showSaveButton (Boolean) — Whether to display a Save button. This parameter is optional. If you do not specify a value, the Recorder displays the Save button (by default). (You can save a recording by calling the saveArchive() method of the Recorder object.)
    • showSettingsButton (Boolean) — Whether to display the settings buttons.
  • width (Number) — The width of the recorder. The default width is 320 pixels.
  • wmode (String) — Set this property to set the transparency of the SWF object used to display the recorder. Possible values match the wmode values for the object and embed tags for a SWF file: "opaque", "transparent" (the default), or "window". (For more information, see Flash OBJECT and EMBED tag attributes (at adobe.com).

To remove the recorder from the page, call the removeRecorder() method.

Returns

Recorder — The Recorder object.

removePlayer(player:Player)

Removes the specified player from the HTML DOM.

Parameters

player (Player) — The player to remove.

The application throws an error if the player does not exist in the HTML DOM.

removeRecorder(recorder:Recorder)

Removes the specified recorder from the HTML DOM.

Parameters

recorder (Recorder) — The recorder to remove.

The application throws an error if the recorder does not exist in the HTML DOM.

Example

The following code shows you how to use the RecorderManager, Recorder, and Player classes.

var recorderManager;
var recorder;
var player;
var TOKEN = ""; // Replace with a generated token that has been assigned the role of moderator.
                // See https://dashboard.tokbox.com/projects
var API_KEY = "";  // Replace with your API key. See https://dashboard.tokbox.com/projects

recorderManager = TB.initRecorderManager(API_KEY);

var recDiv = document.createElement("div");
var recDivId = "recorder" + new Date().getTime().toString();
recDiv.setAttribute("id", recDivId);
document.getElementById("recorderContainer").appendChild(recDiv); // Replace with the ID of the container DOM element.
recorder = recorderManager.displayRecorder(TOKEN, recDivId);
recorder.addEventListener("archiveSaved", archiveSavedHandler);

function archiveSavedHandler(event) {
	recorderManager.removeRecorder(recorder);
	loadArchive(event.archives[0].archiveId); // You will want to save the archive ID on your server, for future playback.
}

function loadArchive(archiveId) {
	playerDiv = document.createElement("div");
	var playerDivId = "player" + archiveId;
	playerDiv.setAttribute("id", playerDivId);
	document.getElementById("playerContainer").appendChild(playerDiv)
	player = recorderManager.displayPlayer(archiveId, TOKEN, playerDivId);
}

IRC Live Chat

Have a quick question? Chat with TokBox Support on IRC. Join chat