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

Archive class

The Archive class defines an object that represents an OpenTok archive.

You get a reference to an Archive object from an ArchiveEvent object or from a SessionEvent object. These objects include an archives property, which is an array of Archive objects.

The sessionConnected event object (defined by the SessionEvent class) includes an archives property. This property represents an array of archives that are currently created for the session.

Archive properties

Archive objects include the following properties:

archiveId (String) – A unique identifier for the archive. Note that you should store a record of the archive IDs of archives you create, so that you can reference them later when loading the archive for playback.

title (String) – The title assigned to the archive when it was created (when the createArchive() method of a Session object was called).

type (String) – A string identifying the type of archive. This can be one of the following values:

  • "perSession" – Defines an archive that records all streams in a session.
  • "perStream" – Defines an archive that can be used to record selected streams in a session.
  • "individual" – Defines an archive that is recorded using the Recorder class. (This is an archive of a single video, recorded independently from an OpenTok session.)

Note:Archive properties should only be used as read-only entities. The results of using JavaScript to directly change the values of Archive properties will be unpredictable.

Archive methods

Archive objects have the following methods:

Method Description
getStateManager():StateManager Returns the StateManager object for the session, with which you can listen to state data changes in the archive.
startPlayback() Starts playing back the archive.
stopPlayback() Stops playing back the archive.

getStateManager():StateManager

Returns the StateManager object for the Archive. For an example, see the example in the StateManager documentation.

Note: The Archive State API is in beta testing. We welcome your comments.

Returns

StateManager — The StateManager object for the Archive.

startPlayback()

Starts playing back the archive.

Note: If all clients disconnect from a session, any archive playing in that session stops.

Events

playbackStarted (ArchiveEvent) — Dispatched by the Session object on all connected clients.

exception (ExceptionEvent) — The OpenTok library could not play back the archive. The TB object dispatches this event. The event object includes these properties:

code

title

message

3003

"Playback start exception"

"An error occurred when starting playback."

Errors

The application throws an error if the archive is a created archive (used for recording), rather than a loaded archive (used for playback).

stopPlayback()

Stops playing back the archive.

Note: If all clients disconnect from a session, any archive playing in that session stops.

Events

playbackStarted (ArchiveEvent) — The archive playback has started. The Session object dispatches this event.

playbackStopped (ArchiveEvent) — Dispatched by the Session object on all connected clients.

exception (ExceptionEvent) — The OpenTok library could not stop playing back the archive. The TB object dispatches this event. The event object includes these properties:

code

title

message

3003

"Playback stop exception"

"An error occurred when stopping playback."

IRC Live Chat

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