This page provides a reference to all the available JavaScript API calls.
These APIs can be used to enhance the functionality of your embeds, or to implement advanced page interactions.
To interact with the player, you have to initialize it first.
Once the Player has been initialized you can perform API calls.
Example
var options = { clientId: "your clientId here", xcontentId: "an xcontentId here", sessId: "pkey or session token" }; var player = THRONContentExperience("elementId", options); //Now we have the instance: player //Use "on" method: player.on("ready", function(){console.log("Reproducer is ready");})
Methods
-
<static> mediaContainer()
-
- Requires input parameters: no
- Returns a value: yes
- Available for: all content types
This method returns the HTML DOM element containing the object that will reproduce the content.
For example, in this container you will find as child the video HTML element or the audio HTML element.
This method is useful if you want to access the item that will play the content.
We strongly suggest to call this method after the Player's ready event (see example).Returns:
- Type
- HTMLDivElement
Example
var options = { clientId: "your clientId here", xcontentId: "an xcontentId here", sessId: "pkey or session token" }; var player = THRONContentExperience("abwmp1", p1); var onReadyFunction = function () { var mediaContainer = player.mediaContainer(); var videoInstance = mediaContainer.querySelector("video"); console.log("HTMLVideoElement", videoInstance); //Remove listener ready: player.off("ready", onReadyFunction); } //Use "on" method: player.on("ready", onReadyFunction);
-
<static> container()
-
- Requires input parameters: no
- Returns a value: yes
- Available for: all content types
This method returns the HTML DOM element which contains all the Player HTML components.
This method is useful if you want to access all the Player html components and create an advanced customization.
We strongly suggest to call this method after the Player's ready event (see example).
Returns:
- Type
- HTMLDivElement
Example
var options = { clientId: "your clientId here", xcontentId: "an xcontentId here", sessId: "pkey or session token" }; var player = THRONContentExperience("abwmp1", p1); var onReadyFunction = function () { var container = player.container(); console.log("HTMLElement", container); //Remove listener ready: player.off("ready", onReadyFunction); } //Use "on" method: player.on("ready", onReadyFunction);
-
<static> playToggle()
-
- Requires input parameters: no
- Returns a value: no
- Available for: Audio, Audio playlist, Video, Video playlist
This method is useful to switch the playback status of the content: if the content is playing it will be paused and vice versa.
-
<static> play()
-
- Requires input parameters: no
- Returns a value: no
- Available for: Audio, Audio playlist, Video, Video playlist
This method is useful to play the content.
If content is already playing and this method is called, the content will keep playing. -
<static> pause()
-
- Requires input parameters: no
- Returns a value: no
- Available for: Audio, Audio playlist, Video, Video playlist
This method is useful to pause the content.
If content is already paused and this method is called, content will remain in pause. -
<static> seek(position)
-
- Requires input parameters: yes
- Returns a value: no
- Available for: Audio, Audio playlist, Video, Video playlist
This method is useful to move/skip to a new position in the content.
The seek method receives an input parameter equal to the number of seconds from which to start content playback.Parameters:
Name Type Description position
Number The position (in seconds) to seek to
Example
//Seek to seconds 10 var options = { clientId: "your clientId here", xcontentId: "an xcontentId here", sessId: "pkey or session token" }; var player = THRONContentExperience("abwmp1", p1); //On Playing listener: var onPlaying = function () { player.seek(10); //Remove listener playing: player.off("playing", onPlaying); }; //Attach listener: player.on("playing", onPlaying);
-
<static> volume( [volume])
-
- Requires input parameters: no, it's optional
- Returns a value: yes
- Available for: Audio, Audio playlist, Video, Video playlist
This method can be used to set or get the volume level.
Volume method receives an input parameter equal to the desired volume level (from 0 to 1).
If not provided, the method will return the current volume level.Parameters:
Name Type Argument Description volume
Number <optional>
Set the volume of the player between 0-1
Returns:
The current volume value
- Type
- Number
Example
//Set volume to 0 var options = { clientId: "your clientId here", xcontentId: "an xcontentId here", sessId: "pkey or session token" }; var player = THRONContentExperience("abwmp1", p1); //On Playing listener: var onPlaying = function () { player.volume(0); //Print volume: console.log(player.volume()); //Remove listener playing: player.off("playing", onPlaying); }; //Attach listener: player.on("playing", onPlaying);
-
<static> status()
-
- Requires input parameters: no
- Returns a value: yes
- Available for: Audio, Audio playlist, Video, Video playlist
This method returns content playback information.
Returns:
- For video and video playlist the method returns the following informations: canSeek (boolean, if true the content can be seeked), currentTime (number of played seconds), duration (total number of seconds), muted (boolean, if true the current volume level is 0), playing (boolean, if true the content is currently playing), volume (number, current volume level).
- For audio and audio playlist the method returns: playing, currentTime, duration.
- For document the method returns: pages, actualPage
- Type
- Object
-
<static> qualityLevels()
-
- Requires input parameters: no
- Returns a value: yes
- Available for: Video, Video playlist
This method returns a list of information about quality levels of video elements.
Returns:
It returns an array of items, each representing a quality level with the following information:
- bitrate, kbps;
- index, the index of each quality level. Can be used to switch quality using the currentQuality method. If the content is being reproduced in streaming, the -1 index represents the adaptive quality level;
- label, the display name of each quality level;
- url, the url of each quality level.
- Type
- Array
Example
//Get video list of video quality var options = { clientId: "your clientId here", xcontentId: "an xcontentId here", sessId: "pkey or session token" }; var player = THRONContentExperience("abwmp1", p1); //When quality levels are loaded: var onLevelsReady = function () { //Print levels list console.log(player.qualityLevels()); //Remove listener levels: player.off("levels", onLevelsReady); }; player.on("levels", onLevelsReady);
-
<static> currentQuality( [index])
-
- Requires input parameters: no, is optional
- Returns a value: yes
- Available for: Video, Video playlist
This method can be used to set or get the quality level of the video.
Parameters:
Name Type Argument Description index
Number <optional>
Sets video quality to a specified index. You can find the correct index
calling qualityLevels method, taking any object of the returned array. From this object take the value of the index attribute (see the example)Returns:
Returns the index of the current active quality level
- Type
- Number
Example
var onPlaying = function () { var qualities = player.qualityLevels(); if(qualities.length > 0){ var lowestQuality = qualities[0].index; player.currentQuality(lowestQuality); console.log( player.currentQuality()); } //Remove listener playing: player.off("playing", onPlaying); }; player.on("playing", onPlaying);
-
<static> speed( [speed])
-
- Requires input parameters: no, is optional
- Returns a value: yes
- Available for: Video, Video playlist
This method can be used to set or get the playback speed.
The speed method receives an input parameter equal to the desired playback speed. If not provided it returns the current playback speed.
Playback speed values are: 0.5, 0.75, 1, 1.25, 1.5, 2.Parameters:
Name Type Argument Description speed
Number <optional>
Valid values are: 0.5, 0.75, 1, 1.25, 1.5, 2
calling qualityLevels method, taking any object of the returned array. From this object take the value of the index attribute (see the example)Returns:
Returns the playback speed
- Type
- Number