AAMP Engine Javascript API References

API
Published: October 10, 2019
Edited: November 29, 2019

Class AAMPlayer

Description

Class AAMPPlayer is a Unified Video Engine (UVE) interface which provides JavaScript binding APIs to interact with AAMP (Advanced Adaptive Media Player). AAMP is a native video engine build on top of gstreamer, optimized for performance, memory use, and code size. 

Declaration

var playerObj = new AAMPPlayer();

Methods

load

Parameters:  uri: string

Return Value:  void

Description:  URI of the Media being played by the Video Engine

initConfig

Parameters:  IConfig: Object[]

Return Value:  void

Description:  IConfig Object with key value pair of launch configuration

play

Parameters:  none

Return Value:  void

Description:  Starts playback when enough data is buffered at playhead

pause

Parameters:  none

Return Value:  void

Description:  Pauses playback

stop

Parameters:  none

Return Value:  void

Description:  Stop playback and free resources

seek

Parameters:  timeSec: number

Return Value:  void

Description:  Performs a seekrn@param timeSec the time in seconds to seek

getCurrentState

Parameters:  none

Return Value:  PlayState

Description:  Gets the current state.rnThis defaults to PlayState.PAUSED

getDurationSec

Parameters:  none

Return Value:  number

Description:  Gets the duration of the content in seconds.

getCurrentPosition

Parameters:  none

Return Value:  number

Description:  Gets the current user time in seconds.

getVideoBitrates

Parameters:  none

Return Value:  number

Description:  Gets available video bitrates

getCurrentVideoBitrate

Parameters:  none

Return Value:  number

Description:  Gets the current video bitrate

setVideoBitrate

Parameters:  bitrate: number

Return Value:  void

Description:  Sets the current video bitrate

getCurrentAudioBitrate

Parameters:  none

Return Value:  number

Description:  Gets the current audio bitrate

getVolume

Parameters:  none

Return Value:  number

Description:  Gets the current volume (value between 0 and 1)

setVolume

Parameters:  volume: number

Return Value:  void

Description:  Sets the current volume (value between 0 and 1)

getPlaybackRate

Parameters:  none

Return Value:  number

Description:  Gets the current playback rate

setPlaybackRate

Parameters:  rate: number, overshoot:number ?= 0

Return Value:  void

Description:  Sets the current playback rate and overshoot if necessary

setVideoMute

Parameters:  enabled: boolean

Return Value:  void

Description:  Black out the video for parental controls

setSubscribedTags

Parameters:  tagNames: string []

Description:  // DAI Subscribe to specific tags / DOM Element.rnUsed to identify Content Break period

addEventListener

Parameters:  name: string, handler: Function

removeEventListener

Parameters:  name: string, handler: Function

setDRMConfig

Parameters:  config: DRMConfig

Description:  Set the DRM config params

addCustomHTTPHeader

Parameters:  headerName: string, headerValue: string []

Description:  Add custom headers to HTTP requests

removeCustomHTTPHeader

Parameters:  headerName: string

Description:  Remove a custom headers set previously, with empty args will delete all

setVideoRect

Parameters:  x: number, y: number, w: number, h: number

Description:  Set display video rectangle co-ordinates

setVideoZoom

Parameters:  videoZoom: string

Description:  Set video zoom

Properties

IConfig

Property IConfig with key value pair for launch configuration

initialBitrate

Data Type:   number

Description:   max initial bitrate (kbps)

offset

Data Type:   number

Description:   start position offset (ms)

networkTimeout

Data Type:   number

Description:   network request timeout (ms)

downloadBuffer

Data Type:   number

Description:   max amount of time to download ahead of playhead (seconds)rne.x: with a downloadBuffer of 10s there will be 10 seconds of video or audio stored in javascript memory and not in arnvideo or audio stored in javascript memory and not in arnplayback buffer

preferredAudioLanguage

Data Type:   string

drm

Data Type:   DRMConfig

networkProxy

Data Type:   string

Description:   network proxy to use (Format ://)

licenseProxy

Data Type:   string

Description:   network proxy to use for license requests (Format same as network proxy)

DRM Config

DRM Configuration Property with key value pair.

DRM Configuration Property with key value pair.

Usage

drmConfig = {
'com.microsoft.playready': 'http://test.playready.microsoft.com/service/rightsmanager.asmx';
'com.widevine.alpha': 'https://widevine-proxy.appspot.com/proxy';
'preferredKeysystem': 'com.widevine.alpha';
};

Player Events

playbackStateChanged

Payload:   state: number

Description:   fired as state changes across play/pause seek/not-seek quadruplet

playbackProgressUpdate

Payload:   durationMiliseconds: number,
positionMiliseconds: number,
playbackSpeed: number,
startMiliseconds: number,
endMiliseconds: number

Description:   fired based on the interval set

playbackCompleted

Description:   fired when there is nothing left to play

playbackSpeedChanged

Payload:   speed: number,
reason: string

playbackStateChanged

Payload:   shouldRetry: boolean,
code: number,
description: string

Description:   fired when an error occurs

decoderAvailable

Payload:   decoderHandle: number

Description:   fired when video decoder handle becomes available, required for closedcaption parsing + rendering by RDK ClosedCaptions module

mediaMetadata

Payload:   durationMiliseconds: number,
languages: string[],
bitrates: number[],
playbackSpeeds: number[],
width: number,
height: number,
hasDrm: boolean

Description:   fired with metadata of the asset currently played, includes duration(in ms), audio language list, available bitrate list, hasDrm, supported playback speeds

speedsChanged

Payload:   playbackSpeeds: number[]

Description:   fired when supported playback speeds changes (based on iframe availability)

Player States

Player States

Idle

Playing

Paused

Seeking

Player Errors

AAMP_TUNE_INIT_FAILED

Media Error:   10

Error String:   AAMP: init failed

Remarks:   Fragmentcollector initialization failed

AAMP_TUNE_MANIFEST_REQ_FAILED

Media Error:   10

Error String:   AAMP: Manifest Download failed

Remarks:   Playlist refresh failed

AAMP_TUNE_AUTHORISATION_FAILURE

Media Error:   40

Error String:   AAMP: Authorization failure

AAMP_TUNE_FRAGMENT_DOWNLOAD_FAILURE

Media Error:   10

Error String:   AAMP: fragment download failures

AAMP_TUNE_INIT_FRAGMENT_DOWNLOAD_FAILURE

Media Error:   10

Error String:   AAMP: init fragment download failed

AAMP_TUNE_UNTRACKED_DRM_ERROR

Media Error:   50

Error String:   AAMP: DRM error untracked error

AAMP_TUNE_DRM_INIT_FAILED

Media Error:   50

Error String:   AAMP: DRM Initialization Failed

AAMP_TUNE_DRM_DATA_BIND_FAILED

Media Error:   50

Error String:   AAMP: InitData-DRM Binding Failed

AAMP_TUNE_DRM_CHALLENGE_FAILED

Media Error:   50

Error String:   AAMP: DRM License Challenge Generation Failed

AAMP_TUNE_LICENCE_TIMEOUT

Media Error:   50

Error String:   AAMP: DRM License Request Timed out

AAMP_TUNE_LICENCE_REQUEST_FAILED

Media Error:   50

Error String:   AAMP: DRM License Request Failed

AAMP_TUNE_INVALID_DRM_KEY

Media Error:   50

Error String:   AAMP: Invalid Key Error, from DRM

AAMP_TUNE_UNSUPPORTED_STREAM_TYPE

Media Error:   50

Error String:   AAMP: Unsupported Stream Type

Remarks:   Unable to determine stream type for DRM Init

AAMP_TUNE_FAILED_TO_GET_KEYID

Media Error:   50

Error String:   AAMP: Failed to parse key id from PSSH

AAMP_TUNE_FAILED_TO_GET_ACCESS_TOKEN

Media Error:   50

Error String:   AAMP: Failed to get access token from Auth Service

AAMP_TUNE_CORRUPT_DRM_DATA

Media Error:   51

Error String:   AAMP: DRM failure due to Corrupt DRM files

AAMP_TUNE_CORRUPT_DRM_METADATA

Media Error:   50

Error String:   AAMP: DRM failure due to Bad DRMMetadata in stream

AAMP_TUNE_DRM_DECRYPT_FAILED

Media Error:   50

Error String:   AAMP: DRM Decryption Failed for Fragments

AAMP_TUNE_GST_PIPELINE_ERROR

Media Error:   80

Error String:   AAMP: Error from gstreamer pipeline

AAMP_TUNE_PLAYBACK_STALLED

Media Error:   7600

Error String:   AAMP: Playback was stalled due to lack of new fragments

AAMP_TUNE_CONTENT_NOT_FOUND

Media Error:   20

Error String:   AAMP: Resource was not found at the URL(HTTP 404)

AAMP_TUNE_DRM_KEY_UPDATE_FAILED

Media Error:   50

Error String:   AAMP: Failed to process DRM key

AAMP_TUNE_DEVICE_NOT_PROVISIONED

Media Error:   52

Error String:   AAMP: Device not provisioned

AAMP_TUNE_INVALID_MANIFEST_FAILURE

Media Error:   10

Error String:   AAMP: Invalid Manifest, parse failed

AAMP_TUNE_FAILED_PTS_ERROR

Media Error:   80

Error String:   AAMP: Playback failed due to PTS error

AAMP_TUNE_FAILURE_UNKNOWN

Media Error:   100

Error String:   AAMP: Unknown Failure

See Related: AAMP Engine QuickStart