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
The Player class lets you individually play back stand-alone archives that were recorded with a Recorder object.
The Player includes a button for starting playback. The Player object
playbackStarted when playback starts. The Player object
playbackStopped event when playback stops. The Player object
playbackPaused event when playback is paused.
Note: To playback an archive in an OpenTok session (so that all participants can display the
recording), use the
methods. Use the Player class to playback a stand-alone archive in a local client page only
(not in multiple clients connected to an OpenTok session).
For an example of using the Player class, see the example in the RecorderManager documentation.
Player objects have the following methods:
|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 Player video.|
|loadArchive(archiveId:String)||Loads the specified archive into the Player.|
|pause()||Causes the Player to pause the archive.|
|play()||Causes the Player to start playing the loaded archive.|
|removeEventListener(eventType:String, listener:Function)||Removes an event listener for a specific event.|
|stop()||Causes the Player to stop playing the loaded archive.|
Registers a method as an event listener for a specific event.
type (String) This string identifying the type of event. See Player 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 Player 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 = player.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
Loads an archive into the Player. When the archive loads, the Player object dispatches an
event and the archive starts playing back.
Note: When you instantiate a Player object, by calling the
displayPlayer() method of the
RecorderManager class, you pass in an archive ID for the initial playback. You only need to call the
method if you want to load a new archive into the Player.
archiveId (String) The archive ID of the archive you want to load and play back.
archiveLoaded (Event) The archive was loaded.
Causes the Player to pause playback of the loaded archive. If the archive is not playing, calling this method has no effect.
The end-user on your site can also stop playing the archive by clicking the Pause button.
playbackPaused (Event) The playback of the video paused.
Causes the Player to start playing the loaded archive. If the archive is already playing, calling this method has no effect.
The end-user on your site can also start playing the archive by clicking the Play button.
playbackStarted (Event) The playback of the video started.
Removes an event listener for a specific event.
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.
Causes the Player to stop playing the loaded archive. If the archive is not playing, calling this method has no effect.
playbackStopped (Event) The playback of the video stopped.
A Player object can dispatch the following events:
|Event type||Event class||Description|
||Event||The archive was loaded.|
||Event||Playback of the archive has been paused.|
||Event||Playback of the archive started.|
||Event||Playback of the archive stopped.|