-
addEventListener(type, listener, useCapture)
-
Registers a listener on the specified event.
The possible event types are:
- 'error' (see error event specification)
- 'warning' (see warning event specification)
- 'manifestUrlUpdate' (see manifestUrlUpdate event specification)
- 'play_bitrate' (see play_bitrate event specification)
- 'download_bitrate' (see download_bitrate event specification)
- 'bufferLevel_updated' (see bufferLevel_updated event specification)
- 'state_changed' (see state_changed event specification)
- 'cueEnter' (see cueEnter event specification)
- 'cueExit' (see cueExit event specification)
Parameters:
Name |
Type |
Description |
type |
string
|
the event type for listen to, either any HTML video element event or player event. |
listener |
callback
|
the callback which is called when an event of the specified type occurs |
useCapture |
boolean
|
see HTML DOM addEventListener() method specification |
-
addPlugin(plugin)
-
Adds a MediaPlayer plugin.
Parameters:
Name |
Type |
Description |
plugin |
object
|
the plugin instance |
-
attachTTMLRenderingDiv(div)
-
Attaches an HTML div element to be used to render rich TTML subtitles.
Parameters:
Name |
Type |
Description |
div |
HTMLDivElement
|
An unstyled div element placed after the video element. It will be styled to match the video size and overlay z-order |
-
enableSubtitleExternDisplay(mode)
-
Enables or disables subtitles display in a div outside video player.
Parameters:
Name |
Type |
Description |
mode |
boolean
|
true if subtitles are displayed in a div outside video player |
-
enableSubtitles(value)
-
Enable or disables subtitles processing.
Parameters:
Name |
Type |
Description |
value |
boolean
|
true to enable subtitles, false to disables subtitles processing (by default subtitles are disabled) |
-
getAutoPlay()
-
Returns the autoplay state.
Returns:
the autoplay state
-
Type
-
boolean
-
getAutoSwitchQuality()
-
Returns the auto switch quality state.
Returns:
the auto switch quality state
-
Type
-
boolean
-
getBuildDate()
-
Returns the date at which this player has been built.
Returns:
the date at which this player has been built
-
Type
-
string
-
getDebug()
-
Returns the debug object.
Returns:
the debug object
-
Type
-
object
-
getDefaultAudioLang()
-
Gets the default audio language.
Returns:
lang - the default audio language based on ISO 3166-2
-
Type
-
string
-
getDefaultSubtitleLang()
-
Gets the default subtitle language.
Returns:
lang - the default subtitle language based on ISO 3166-2
-
Type
-
string
-
getDuration()
-
Returns the media duration.
Returns:
the media duration in seconds, Infinity for live content
-
Type
-
number
-
getDVRSeekOffset(value)
-
TBD
Parameters:
Name |
Type |
Description |
value |
|
|
Returns:
DVR seek offset
-
getDVRWindowRange()
-
Return the available DVR window range in case of live streams.
Returns:
-
range - the DVR window range
-
Type
-
object
-
range.start - the DVR window range start time
-
Type
-
number
-
range.end - the DVR window range end time
-
Type
-
number
-
range.programStart - the DVR window range absolute program start date/time (if available, may be undefined)
-
Type
-
number
-
range.programEnd - the DVR window range absolute program end date/time (if available, may be undefined)
-
Type
-
number
-
getDVRWindowSize()
-
Returns the DVR window size.
Returns:
the DVR window size in seconds
-
Type
-
number
-
getError()
-
Returns the Error object for the most recent error.
Returns:
the Error object for the most recent error, or null if there has not been an error
-
Type
-
object
-
getMetricsExt()
-
Returns the metrics extension object.
Returns:
the metrics extension object
-
Type
-
object
-
getMetricsFor(type)
-
Returns the metrics for stream type.
Parameters:
Name |
Type |
Description |
type |
string
|
stream type, 'video' or 'audio' |
Returns:
the metrics array for the selected type
-
Type
-
Array
-
getMute()
-
Returns the audio mute state.
Returns:
true if the audio is muted, false otherwise
-
Type
-
boolean
-
getPosition()
-
Returns the current playback time/position.
Returns:
the current playback time/position in seconds
-
Type
-
number
-
getQualityFor(type)
-
Returns the current quality for a stream type.
Parameters:
Name |
Type |
Description |
type |
string
|
stream type, 'video' or 'audio' |
Returns:
the current quality level as an index of the quality (in bitrate ascending order)
-
Type
-
number
-
getScheduleWhilePaused()
-
Returns the buffering behaviour while the player is in pause.
Returns:
true if the player still buffers stream while in pause
-
Type
-
boolean
-
getSelectedTrack(type)
-
Returns the selected track for the stream type.
Parameters:
Name |
Type |
Description |
type |
String
|
the stream type according to MediaPlayer.TRACKS_TYPE (see @link MediaPlayer#TRACKS_TYPE) |
Returns:
the selected track
-
Type
-
Track
-
getTerminalId()
-
Returns the terminal ID.
Returns:
the terminal ID (--)
-
Type
-
string
-
getTracks(type)
-
Returns the list of available tracks for the stream type (as specified in the stream manifest).
The tracks list can be retrieved once the video 'loadeddata' event has been fired.
Parameters:
Name |
Type |
Description |
type |
String
|
the stream type according to MediaPlayer.TRACKS_TYPE (see @link MediaPlayer#TRACKS_TYPE) |
Returns:
the available tracks for the stream type
-
Type
-
Array.<Track>
-
getTTMLRenderingDiv()
-
Returns:
the HTML div object previously attached
-
Type
-
HTMLDivElement
-
getVersion()
-
Returns the version of the player.
Returns:
the version of the player
-
Type
-
string
-
getVersionDashJS()
-
Returns the version of dash.js from which this player has been built.
Returns:
the dash.js version
-
Type
-
string
-
getVersionFull()
-
Returns the full version of the player (including git tag).
Returns:
the version of the player including git tag
-
Type
-
string
-
getVideoBitrates()
-
Returns the list of available bitrates (in bitrate ascending order).
Returns:
array of bitrate values
-
Type
-
Array.<Number>
-
getVideoModel()
-
Returns the video model object.
Returns:
the video model object
-
Type
-
object
-
getVolume()
-
Returns the audio volume level.
Returns:
the current audio volume level, from 0.0 (silent) to 1.0 (loudest)
-
Type
-
number
-
getWarning()
-
Returns the Warning object for the most recent warning.
Returns:
the Warning object for the most recent warning, or null if there has not been a warning
-
Type
-
object
-
init(video)
-
Initialize the player.
Parameters:
Name |
Type |
Description |
video |
Object
|
the HTML5 video element used to decode and render the media data |
-
isLive()
-
Returns true if the current stream is a live stream.
Returns:
true if current stream is a live stream, false otherwise
-
Type
-
boolean
-
isSubtitlesEnabled()
-
Returns the subtitles processing state.
Returns:
true if subtitles are enabled, false otherwise
-
Type
-
boolean
-
load(stream)
-
Load/open a video stream.
Parameters:
Name |
Type |
Description |
stream |
object
|
video stream properties object such url, startTime, prodData ...
{
url : "[manifest url]",
startTime : [start time in seconds (optional, only for static streams)],
startOver : [true if start-over DVR stream (optional)],
protocol : "[protocol type]", // 'HLS' to activate native support on Safari/OSx
protData : {
// one entry for each key system ('com.microsoft.playready' or 'com.widevine.alpha')
"[key_system_name]": {
laURL: "[licenser url (optional)]",
withCredentials: "[license_request_withCredentials_value (true or false, optional)]",
cdmData: "[CDM data (optional)]", // Supported by PlayReady key system (using MS-prefixed EME API) only
serverCertificate: "[license_server_certificate (as Base64 string, optional)]",
audioRobustness: "[audio_robustness_level (optional)]", // Considered for Widevine key system only
videoRobustness: "[video_robustness_level (optional)]" // Considered for Widevine key system only
},
...
}
...
}
|
-
pause()
-
Pauses the media playback.
-
play()
-
Plays/resumes playback of the media.
-
removeEventListener(type, listener)
-
Unregisters the listener previously registered with the addEventListener() method.
Parameters:
Name |
Type |
Description |
type |
string
|
the event type on which the listener was registered |
listener |
callback
|
the callback which was registered to the event type |
- See:
-
-
removePlugin(plugin)
-
Removes a MediaPlayer plugin.
Parameters:
Name |
Type |
Description |
plugin |
object
|
string
|
the plugin instance (or name) to remove |
-
reset(reason)
-
Stops and resets the player.
Parameters:
Name |
Type |
Description |
reason |
number
|
the reason for stopping the player.
Possible values are:
- 0 : stop during streaming at user request
- 1 : stop when all streams are completed
- 2 : stop after an error
|
-
seek(time)
-
Seeks the media to the new time. For LIVE streams, this function can be used to perform seeks within the DVR window if available.
Parameters:
Name |
Type |
Description |
time |
number
|
the new time value in seconds |
-
selectTrack(type, track)
-
Selects the track to be playbacked for the stream type.
Parameters:
Name |
Type |
Description |
type |
String
|
the stream type according to MediaPlayer.TRACKS_TYPE (see @link MediaPlayer#TRACKS_TYPE) |
track |
Track
|
the track to select, as returned by the getTracks method |
- See:
-
-
setAutoPlay(value)
-
Sets the autoplay state.
Parameters:
Name |
Type |
Description |
value |
boolean
|
true to activate autoplay, false to disable autoplay |
-
setAutoSwitchQuality(value)
-
Sets the auto switch quality state.
Parameters:
Name |
Type |
Description |
value |
boolean
|
the new auto switch quality state |
-
setConfig(params)
-
Sets player configuration parameters.
Parameters:
-
setDebug(value)
-
Enables or disables debug information in the browser console.
Parameters:
Name |
Type |
Description |
value |
boolean
|
true to enable debug information, false to disable |
-
setDefaultAudioLang(lang)
-
Sets the default audio language. If the default language is available in the stream,
the corresponding audio track is selected. Otherwise, the first declared audio track in the manifest is selected.
Parameters:
Name |
Type |
Description |
lang |
string
|
the default audio language based on ISO 3166-2 |
-
setDefaultSubtitleLang(lang)
-
Sets the default subtitle language. If the default language is available in the stream,
the corresponding subtitle track is selected. Otherwise, the first declared subtitle track in the manifest is selected.
Parameters:
Name |
Type |
Description |
lang |
string
|
the default subtitle language based on ISO 3166-2 |
-
setInitialQualityFor(type, value)
-
Sets the initial quality to be downloaded for the given track type.
This method has to be used before each call to load() method to set the initial quality.
Otherwise, the initial quality is set according to previous bandwidth condition.
Parameters:
Name |
Type |
Description |
type |
string
|
the track type ('video' or 'audio') |
value |
number
|
the new initial quality index (starting from 0) to be downloaded |
- See:
-
-
setMute(value)
-
Sets the audio mute state.
Parameters:
Name |
Type |
Description |
value |
boolean
|
true to mute audio, false otherwise |
-
setQualityFor(type, value)
-
Selects the quality for a stream type.
Parameters:
Name |
Type |
Description |
type |
string
|
stream type, 'video' or 'audio' |
value |
number
|
the selected quality level as an index of the quality (in bitrate ascending order) |
-
setScheduleWhilePaused(value)
-
Sets the buffering behaviour while player is in pause.
Parameters:
Name |
Type |
Description |
value |
boolean
|
true if the player has to buffer stream while in pause |
-
setTrickModeSpeed(speed)
-
Sets the trick mode speed.
Parameters:
Name |
Type |
Description |
speed |
number
|
the new trick mode speed (0 corresponds to normal playback, i.e. playbackRate = 1) |
-
setTrickModeSpeed()
-
Returns the current trick mode speed.
Returns:
the current trick mode speed
-
Type
-
number
-
setVolume(level)
-
Sets the audio volume level.
Parameters:
Name |
Type |
Description |
level |
number
|
the audio volume level, from 0.0 (silent) to 1.0 (loudest) |
-
stop()
-
Stops the media playback and seek back to start of stream and media. Subsequently call to play() method will restart streaming and playing from beginning.