This page covers the Analytics-only JavaScript 3.x SDK. For the recommended implementation, see Implement Streaming Media using the Edge Network.
ADB.Media
Static methods
Configures MediaSDK for tracking. This method should be called once before creating any tracker instances in a page.
Syntax
| code language-javascript |
|---|
|
| table 0-row-3 1-row-3 2-row-3 | ||
|---|---|---|
| Variable Name | Type | Description |
mediaConfig |
ADB.MediaConfig |
Valid media configuration |
appMeasurement |
object | AppMeasurement instance |
Example
| code language-javascript |
|---|
|
Creates an instance of media to track the playback session. Returns null if called before configuring media.
Syntax
| code language-javascript |
|---|
|
| table 0-row-4 1-row-4 1-align-left 2-align-left 3-align-center 4-align-left 6-align-left 7-align-left 8-align-center 9-align-left | |||
|---|---|---|---|
| Variable Name | Type | Required | Description |
trackerConfig |
Tracker configuration | No | Tracker configuration object. |
Example
| code language-javascript |
|---|
|
To override channel or playerName per tracker instance, pass the override values in the tracker configuration object.
Example with tracker configuration
| code language-javascript |
|---|
|
Creates an object containing media information. Returns empty object if invalid parameters are passed.
Syntax
| code language-javascript |
|---|
|
| table 0-row-3 1-row-3 2-row-3 3-row-3 4-row-3 5-row-3 1-align-left 2-align-left 3-align-left 5-align-left 6-align-left 7-align-left 9-align-left 10-align-left 11-align-left 13-align-left 14-align-left 15-align-left 17-align-left 18-align-left 19-align-left 21-align-left 22-align-left 23-align-left | ||
|---|---|---|
| Variable Name | Type | Description |
name |
string | Non empty string denoting media name |
id |
string | Non empty string denoting unique media identifier |
length |
number | Positive number denoting length of media in seconds. Use 0 if length is unknown. |
streamType |
string | Stream type or non empty string to denote media stream type. |
mediaType |
Media type | Type of media (Audio or Video) |
Example
| code language-javascript |
|---|
|
Creates an object containing adbreak information. Returns empty object if invalid parameters are passed.
Syntax
| code language-javascript |
|---|
|
| table 0-row-3 1-row-3 2-row-3 3-row-3 1-align-left 2-align-left 3-align-left 5-align-left 6-align-left 7-align-left 9-align-left 10-align-left 11-align-left 13-align-left 14-align-left 15-align-left | ||
|---|---|---|
| Variable Name | Type | Description |
name |
string | Non empty string denoting adbreak name (pre-roll, mid-roll, and post-roll) |
position |
number | The number position of the ad break within the content, starting with 1 |
startTime |
number | Playhead value at the start of the ad break. |
Example
| code language-javascript |
|---|
|
Creates an object containing ad information. Returns empty object if invalid parameters are passed.
Syntax
| code language-javascript |
|---|
|
| table 0-row-3 1-row-3 2-row-3 3-row-3 4-row-3 1-align-left 2-align-left 3-align-left 5-align-left 6-align-left 7-align-left 9-align-left 10-align-left 11-align-left 13-align-left 14-align-left 15-align-left 17-align-left 18-align-left 19-align-left | ||
|---|---|---|
| Variable Name | Type | Description |
name |
string | Non empty string denoting ad name |
id |
string | Non empty string denoting ad id |
position |
number | The number position of the ad within the adbreak, starting with 1 |
length |
number | Positive number denoting length of the ad |
Example
| code language-javascript |
|---|
|
Creates an object containing chapter information. Returns empty object if invalid parameters are passed.
Syntax
| code language-javascript |
|---|
|
| table 0-row-3 1-row-3 2-row-3 3-row-3 4-row-3 1-align-left 2-align-left 3-align-left 5-align-left 6-align-left 7-align-left 9-align-left 10-align-left 11-align-left 13-align-left 14-align-left 15-align-left 17-align-left 18-align-left 19-align-left | ||
|---|---|---|
| Variable Name | Type | Description |
name |
string | Non empty string denoting chapter name |
position |
number | The position of the chapter within the content, starting with 1 |
length |
number | Positive number denoting length of the chapter |
startTime |
number | Playhead value at start of chapter |
Example
| code language-javascript |
|---|
|
Creates an object containing state information. Returns empty object if invalid parameters are passed.
Syntax
| code language-javascript |
|---|
|
| table 0-row-3 1-row-3 1-align-left 2-align-left 3-align-left 5-align-left 6-align-left 7-align-left | ||
|---|---|---|
| Variable Name | Type | Description |
name |
string | Player State or non empty string denoting state name |
Example
| code language-javascript |
|---|
|
Creates an object containing QoE information. Returns empty object if invalid parameters are passed.
Syntax
| code language-javascript |
|---|
|
| table 0-row-3 1-row-3 2-row-3 3-row-3 4-row-3 1-align-left 2-align-left 3-align-left 5-align-left 6-align-left 7-align-left 9-align-left 10-align-left 11-align-left 13-align-left 14-align-left 15-align-left 17-align-left 18-align-left 19-align-left | ||
|---|---|---|
| Variable Name | Type | Description |
bitrate |
number | Positive number denoting current bitrate (0 if unknown) |
startupTime |
number | Positive number denoting startup time (0 if unknown) |
fps |
number | Positive number denoting current fps (0 if unknown) |
droppedFrames |
number | Positive number denoting number of dropped frames (0 if unknown) |
Example
| code language-javascript |
|---|
|
Returns MediaSDK version.
Syntax
| code language-javascript |
|---|
|
Example
| code language-javascript |
|---|
|
Instance methods
Track the intention to start playback. This starts a tracking session on the media tracker instance. Also see Media Resume.
Syntax
| code language-javascript |
|---|
|
| table 0-row-3 1-row-3 2-row-3 1-align-left 2-align-left 3-align-center 5-align-left 6-align-left 7-align-center 9-align-left 10-align-left 11-align-center | ||
|---|---|---|
| Variable Name | Description | Required |
mediaObject |
Media information created using the createMediaObject method. |
Yes |
contextData |
Optional Media context data. For standard metadata keys, use standard video constants or standard audio constants. | No |
Example
| code language-javascript |
|---|
|
Track media play or resume after a previous pause.
Syntax
| code language-javascript |
|---|
|
Example
| code language-javascript |
|---|
|
Track media pause.
Syntax
| code language-javascript |
|---|
|
Example
| code language-javascript |
|---|
|
Track media complete. Call this method only when the media has been completely viewed.
Syntax
| code language-javascript |
|---|
|
Example
| code language-javascript |
|---|
|
Track the end of a viewing session. Call this method even if the user does not view the media to completion.
Syntax
| code language-javascript |
|---|
|
Example
| code language-javascript |
|---|
|
Track an error in media playback.
Syntax
| code language-javascript |
|---|
|
| table 0-row-3 1-row-3 1-align-left 2-align-left 3-align-center 5-align-left 6-align-left 7-align-center | ||
|---|---|---|
| Variable Name | Description | Required |
errorId |
Non empty string containing error information | Yes |
Example
| code language-javascript |
|---|
|
Method to track media events.
| table 0-row-2 1-row-2 2-row-2 3-row-2 1-align-left 2-align-left 4-align-left 5-align-left 7-align-left 8-align-left 10-align-left 11-align-left | |
|---|---|
| Variable Name | Description |
event |
Media event |
info |
For AdBreakStart event, the adbreak information is created by using the createAdBreakObject method. For AdStart event, the ad information is created by using the createAdObject method. For ChapterStart event, the chapter information is created by using the createChapterObject method. For StateStart and StateEnd events, the state information is created by using the createStateObject method. This is not required for other events. |
contextData |
Optional context data can be provided for AdStart and ChapterStart events. This is not required for other events. |
Syntax
| code language-javascript |
|---|
|
Examples
Tracking AdBreaks
| code language-javascript |
|---|
|
Tracking ads
| code language-javascript |
|---|
|
Tracking chapters
| code language-javascript |
|---|
|
Tracking states
| code language-javascript |
|---|
|
Tracking playback events
| code language-javascript |
|---|
|
Tracking bitrate changes
| code language-javascript |
|---|
|
Provide current media playhead to media tracker. For accurate tracking, call this method whenever playhead changes during playback.
Syntax
| code language-javascript |
|---|
|
| table 0-row-2 1-row-2 1-align-left 2-align-left 4-align-left 5-align-left | |
|---|---|
| Variable Name | Description |
time |
Current playhead in seconds. For video-on-demand (VOD), the value is specified in seconds from the beginning of the media item. For live streaming, if the player does not provide information about the content duration, the value can be specified as the number of seconds since midnight UTC of that day. Note: When using progress markers, the content duration is required and the playhead needs to be updated as number of seconds from the beginning of the media item, starting with 0. |
Example
| code language-javascript |
|---|
|
Provides current QoE information to the media tracker. For accurate tracking, call this method multiple times when the media player provides the updated QoE information.
Syntax
| code language-javascript |
|---|
|
| table 0-row-2 1-row-2 1-align-left 2-align-left 4-align-left 5-align-left | |
|---|---|
| Variable Name | Description |
qoeObject |
Current QoE information that was created by using the createQoEObject method. |
Example
| code language-javascript |
|---|
|
Destroys the tracker instance.
Syntax
| code language-javascript |
|---|
|
Example
| code language-javascript |
|---|
|
Constants
Defines the configuration keys that can be set per tracker instance.
| code language-javascript |
|---|
|
Defines the type of a media that is currently tracked.
| code language-javascript |
|---|
|
Defines the stream type of the content that is currently tracked.
| code language-javascript |
|---|
|
ADB.Media.VideoMetadataKeys, ADB.Media.AudioMetadataKeys, and ADB.Media.AdMetadataKeys provide the context data key strings for standard metadata. For the full list of keys and their corresponding reporting variables, see the Standard metadata variable reference.Defines the type of a tracking event.
| code language-javascript |
|---|
|
Defines standard values for tracking player state.
| code language-javascript |
|---|
|
Constant to denote that the current tracking session is resuming a previously closed session. This information must be provided when starting a tracking session.
Syntax
| code language-javascript |
|---|
|
Example
| code language-javascript |
|---|
|
ADB.MediaConfig
trackingServerchannelplayerNameappVersiondebugLoggingfalse)ssltrue)