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
dispatches a playbackStarted when playback starts. The Player object
dispatches a playbackStopped event when playback stops. The Player object
dispatches a 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 Session.loadArchive() and Archive.startPlayback()
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:
| 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 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.
Parameters
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 archiveLoaded
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 loadArchive()
method if you want to load a new archive into the Player.
Parameters
archiveId (String) The archive ID of the archive you want to load and play back.
Events dispatched
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.
See
Events dispatched
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.
Events dispatched
playbackStarted (Event) The playback of the video started.
See
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
Causes the Player to stop playing the loaded archive. If the archive is not playing, calling this method has no effect.
Events dispatched
playbackStopped (Event) The playback of the video stopped.
See
A Player object can dispatch the following events:
| Event type | Event class | Description |
|---|---|---|
"archiveLoaded" |
Event | The archive was loaded. |
"playbackPaused" |
Event | Playback of the archive has been paused. |
"playbackStarted" |
Event | Playback of the archive started. |
"playbackStopped" |
Event | Playback of the archive stopped. |