The OpenTok 2.0 archiving feature lets you record OpenTok 2.0 sessions.
The OpenTok 2.0 archiving feature requires that you use the OpenTok 2.2 JavaScript library. See the important notes in OpenTok 2.2 Archiving JavaScript changes.
The OpenTok JavaScript API includes events that are dispatched when the archive recording starts and when the archive recording stops:
While an archive is being recorded, each OpenTok publisher displays a recording notification indicator.
Use the OpenTok 2.0 Archiving REST API to start, stop, and manage archives.
The Session object dispatches an archiveStarted event when an archive of the session starts recording. The Session object also dispatches an archiveStarted event when you connect to a session that has a recording in progress.
The event object includes the following properties:
- id -- The archive ID.
- name -- The name of the ID.
The following code registers event listeners for the archiveStarted event:
session.addEventListener("archiveStarted", function (event) {
console.log("Archive started."
console.log("- id:" + event.archiveId)
console.log("- name:" + event.name)
}
The Session object dispatches an archiveStopped event when an archive of the session stops recording.
The event object includes the following properties:
- id -- The archive ID.
- name -- The name of the ID.
The following code registers event listeners for the archiveStopped event:
session.addEventListener("archiveStopped", function (event) {
console.log("Archive started."
console.log("- id:" + event.archiveId)
console.log("- name:" + event.name)
}
The OpenTok 2.0 archiving feature requires that you use a pre-release version of the OpenTok 2.2 JavaScript library:
<script src="http://static.opentok.com/webrtc/v2.2/js/TB.min.js"></script>
When released, the OpenTok 2.2 JavaScript library will include other new features in addition to archiving.
The OpenTok 2.2 JavaScript library includes some change that are not backward compatible with OpenTok 2.0:
-
The
sessionConnected
event dispatched by the Session object -- Thestreams
andconnections
properties are deprecated (and these are now empty arrays). For streams and connections in the session when you connect, the Session object dispatches individualstreamCreated
andconnectionCreated
events (for each stream and connection). However, the Session object does not dispatch aconnectionCreated
event for the client's own connection. For the client's own connection, the Session object dispatches asessionConnected
event only. -
The
streamCreated
event dispatched by the Session object -- The Session object dispatches thestreamCreated
event for streams published by other clients only. The event includes a new property:stream
(a Stream object corresponding to the new stream). Thestreams
property is deprecated. -
The
streamCreated
event dispatched by the Publisher object -- The Publisher dispatches thestreamCreated
event for the stream published by the Publisher object. Thestream
property of the event is a reference to the Stream object. -
The
connectionCreated
event dispatched by the Session object -- The ConnectionCreatedEvent class now has aconnection
property, and theconnections
property is deprecated. The Session object now dispatches theconnectionCreated
event for each connection added to the session, including other clients' connections that exist when you first connect. -
The
connectionDestroyed
event dispatched by the Session object -- The ConnectionDestroyedEvent class now has aconnection
property, and theconnections
property is deprecated. The Session object now dispatches theconnectionDestroyed
event for each connection that leaves the session while your client is connected. -
The
streamDestroyed
event dispatched by the Session object -- The Session object dispatches thestreamDestroyed
event for destroyed streams from other clients only. The event includes a new property:stream
(a Stream object corresponding to the destroyed stream). Thestreams
property is deprecated. -
The
streamDestroyed
event dispatched by the Publisher object -- The Publisher dispatches thestreamDestroyed
event when the stream published by the Publisher object is destroyed. Thestream
property is a reference to the Stream object. The default behavior of this event is to remove the Publisher from the HTML DOM. You can cancel the default behavior by calling thepreventDefault()
method of the event object. -
The
sessionDisconnected
event dispatched by the Session object -- Calling thepreventDefault()
method no longer causes a Publisher to be preserved. The Publisher is destroyed by default when the Publisher dispatches the streamDestroyed event. (You can preserve the Publisher by calling thepreventDefault()
method of thestreamDestroyed
event dispatched by the Publisher object.) -
In the
Session.signal()
method, the optionalto
property of thesignal
parameter takes a single Connection object (defining the connection to which the signal will be sent). Theto
property does not take an array of Connection objects, like it did in version 2.0 of the JavaScript library.