25.3.2231.6R Player
new Player ()
Create instance of player.
In this version, only 1 player is supported.
Classes
- Player
Methods
-
static Player.getCapability () {Object}
-
Get Player Capability.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
max_decoder
Number Maximum number of hardware decoder. Switch to software decode if exceed the limit. -
getAudioStats () {Object}
-
Get Audio Decoder statistics
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
input_buffer_count
Number The number of queued input buffers. rendered_output_buffer_count
Number The number of rendered output buffers. dropped_buffer_count
Number The number of dropped buffers. A dropped buffer is an buffer that was supposed to be decoded/rendered, but was instead dropped because it could not be rendered in time. elapsed_ms
Number The total elapsed time since playback started, in milliseconds bitrate
Number The estimated bitrate, in bits per second bytes_transferred
Number The total number of bytes transferred, in bytes. -
getAudioTrack () {Object}
-
Gets the information about audio track.
Returns:
Name Type Description object
Object Name Type Description selected
Number track index currently selected status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
tracks
Array.<Object> An array of object track information. Name Type Description id
Number identify of the track for selecting lang
String a language code in either way of ISO-639-1 or ISO-639-2.
When the language is unknown or could not be determined, language code "und" is returned.When Vermatrix is not enabled (default), Exoplayer will be selected. The following members will be available.
streamType
String The name of the codec of the stream, derived from the codec or MIME type. mimeType
String MIME type of the format. codec
String Codecs of the format as described in RFC 6381.
When the codec is unknown or could not be determined, null will be returned.sample_rate
Number The audio sampling rate in Hz, or -1 if unknown or not applicable. bitrate
Number The bitrate in bits per second. -1 if unknown or not applicable. num_of_channels
Number Number of audio channels -
getBlank () {Object}
-
Get the current blank status.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.ERROR
result
Boolean true
orfalse
-
getDuration () {Object}
-
Gets the duration of the current playback.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
result
Number The duration in milliseconds.
If no duration is available (for example, if streaming live content), -1 is returned. -
getMute () {Object}
-
Get the current mute status.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.ERROR
result
Boolean true
orfalse
-
getOsdResolution () {Object}
-
Get OSD resolution available for positioning the video window.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
width
Number The width of on screen resolution, in pixels. height
Number The height of on screen resolution, in pixels. -
getPlayPosition () {Object}
-
Gets the current playback position.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
result
Number The current position in milliseconds -
getSource () {Object}
-
Get the current source of player.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
source
String current source. config
Object Configuration. Please refer to Player#setSource
-
getSpeed () {Object}
-
Get the current playback speed.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
result
Number current speed. -
getTextTrack () {Object}
-
Gets the information about text track.
Returns:
Name Type Description object
Object Name Type Description selected
Number track index currently selected, -1 when no text selected status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
tracks
Array.<Object> An array of object track information. Name Type Description id
Number identify of the track for selecting type
String type of text track, e.g. subtitle, teletext and timedText mimeType
String MIME type of the format. lang
String a language code in either way of ISO-639-1 or ISO-639-2.
When the language is unknown or could not be determined, language code "und" is returned. -
getVideoRect () {Object}
-
Get current on screen position of video window.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
x
Number The visual x position of video window, in pixels. y
Number The visual y position of video window, in pixels. width
Number The width of video window, in pixels. height
Number The height of video window, in pixels. -
getVideoRotation () {Object}
-
Get video rotation parameters.
Returns:
Name Type Description object
Object Name Type Description angle
Number Angle of rotation x
Number X coordinate of the video after rotation y
Number Y coordinate of the video after rotation status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
-
getVideoStats () {Object}
-
Get Video Decoder statistics
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
input_buffer_count
Number The number of queued input buffers. rendered_output_buffer_count
Number The number of rendered output buffers. dropped_buffer_count
Number The number of dropped buffers. A dropped buffer is an buffer that was supposed to be decoded/rendered, but was instead dropped because it could not be rendered in time. elapsed_ms
Number The total elapsed time since playback started, in milliseconds bitrate
Number The estimated bitrate, in bits per second bytes_transferred
Number The total number of bytes transferred, in bytes. -
getVideoTrack () {Object}
-
Gets the information about video track.
Returns:
Name Type Description object
Object Name Type Description selected
Number track index currently selected status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
tracks
Array.<Object> An array of object track information. Name Type Description id
Number identify of the track When Vermatrix is not enabled (default), Exoplayer will be selected. The following members will be available.
width
Number The width of the video in pixels, or -1 if unknown or not applicable. height
Number The height of the video in pixels, or -1 if unknown or not applicable. streamType
String The name of the codec of the stream, derived from the codec or MIME type. mimeType
String MIME type of the format. codec
String Codecs of the format as described in RFC 6381.
When the codec is unknown or could not be determined, null will be returned.frame_rate
Number The frame rate in frames per second.
The frame rate in frames per second, or -1 if unknown or not applicable.bitrate
Number The bitrate in bits per second. -1 if unknown or not applicable. -
getVolume () {Object}
-
Get Player Volume.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
left
Number Left volume scalar (0 to 1.0) right
Number Right volume scalar (0 to 1.0) -
isLiveStream () {Object}
-
Returns true if current source is live.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
result
boolean if current source is live -
play (speed) {Object}
-
Play the video source at specified speed.
Use speed=0 to pause, speed=1 for normal play and speed < 0 to rewind.Name Type Description speed
Number The desired speed to be played.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
or
ENABLE.status.INVALID_ARGUMENT
-
release () {Object}
-
Releases resources associated with this player object.
The instance of player will no longer usable. new ENABLE.player() to create new create is needed.Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
-
reset () {Object}
-
Resets the player to its uninitialized state.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
-
seekTo (offset) {Object}
-
Seeks to specified time position.
Name Type Description offset
Number The offset in milliseconds from the start to seek to.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
or
ENABLE.status.INVALID_ARGUMENT
-
setAudioTrack (id) {Object}
-
Select an audio track
Name Type Description id
Number Track id of audio
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.INVALID_ARGUMENT
-
setBlank (isBlank) {Object}
-
Blank the video screen.
Name Type Description isBlank
Boolean Pass
true
to blank orfalse
to unblankReturns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.INVALID_ARGUMENT
-
setEventCallback (callback) {Object}
-
Register player callback function for JavaScript application.
Only one callback function can be registered. Passnull
to unregister.
Example:var callback = function(obj) { if (obj.event === ENABLE.video.VIDEOEVENT_STREAM_STARTED){ console.log("playback started!"); } }; video.setEventCallback(callback);
Name Type Description callback
Player~Callback Callback function will be involved when events arrived.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.INVALID_ARGUMENT
-
setMute (isMute) {Object}
-
Mute the player of current application.
Name Type Description isMute
Boolean Pass
true
to mute orfalse
to unmuteReturns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.INVALID_ARGUMENT
-
setSource (url, config ) {Object}
-
Set source of player
DASH :http://<host>:<port>/[<file_path|playlist_path>]
// Play a clear DASH stream
var videoControl = new ENABLE.player(); var config = {playnow:true, encryption_type: ENABLE.video.NO_ENCRYPTION}; videoControl.open("http://www.aminocom.com/videos/sample_enc.mpd", config);
// Play an widevine encrypted DASH stream
var config = {encryption_type: "com.widevine.alpha", encrypting_server: "http://demo.aminocom.com/license"}; videoControl.open("http://www.aminocom.com/videos/sample_enc.mpd", config);
// Play an widevine encrypted DASH stream with persistent license
var config = {encryption_type: "com.widevine.alpha", encrypting_server: "http://demo.aminocom.com/license", drm_session_type: "persistent"}; videoControl.open("http://www.aminocom.com/videos/sample_enc.mpd", config);
// Play an widevine encrypted DASH stream with custom headers when requesting encryption license
var config = { encryption_type: "com.widevine.alpha", encrypting_server: "http://demo.aminocom.com/license", encrypting_request_header: {"header_a": ".....", "header_b": "...."} } videoControl.open("http://www.aminocom.com/videos/sample_enc.mpd", config);
Name Type Description url
String URL of video source.
config
Object optional Configuration.
Name Type Description blank_when_open
boolean optional Default: true. Blank video during channel zapping and unblank when first frame rendered.
mute_when_open
boolean optional Default: true. Mute audio during channel zapping and unmute when first frame rendered.
encryption_type
String optional Encryption type, one of
ENABLE.player.NO_ENCRYPTION
,ENABLE.player.WIDEVINE
orENABLE.player.PLAYREADY
.encrypting_server
String optional Encrypting server URL.
encrypting_request_header
Object optional Additional headers for requesting the encryption license.
drm_session_type
String optional Set persistent for the type of drm session to make the license and key(s) persisted (Widevine server have to enable it).
loop_on_end
boolean optional Default: false. Set true to replay the video upon video end.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.ERROR
or
ENABLE.status.INVALID_ARGUMENT
-
setTextTrack (id) {Object}
-
Select a text track
Name Type Description id
Number Track id of text track
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.INVALID_ARGUMENT
-
setVideoRect (x, y, width, height) {Object}
-
Set on screen position for the video window.
Pass -1 for width and height to reset video to full screenName Type Description x
Number Sets the visual x position of video window, in pixels.
y
Number Sets the visual y position of video window, in pixels.
width
Number The width of video window, in pixels.
height
Number The height of video window, in pixels.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
-
setVideoRotation (angle, x , y ) {Object}
-
Set video rotation
Supported degrees of 0, 90, 180 and 270 only
Input x and y will override x,y of setVideoRect() when degree is 90 and 270Name Type Description angle
Number Angle of rotation
x
Number optional X coordinate of the video after rotation
y
Number optional Y coordinate of the video after rotation
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.INVALID_ARGUMENT
-
setVolume (left, right) {Object}
-
Set Player Volume. This API controls volume of browser application, not Android system.
Name Type Description left
Number Left volume scalar (0 to 1.0)
right
Number Right volume scalar (0 to 1.0)
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.INVALID_ARGUMENT
-
stop () {Object}
-
Stops playback after playback has been started or paused.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
-
unsetTextTrack () {Object}
-
Deselect text track.
Returns:
Name Type Description object
Object Name Type Description status_code
String ENABLE.status.SUCCESS
or
ENABLE.status.NOT_READY
Type Definitions
-
Callback (object)
-
Callback function for
Player#setEventCallback
Name Type Description object
Object Name Type Description event
Object Possible values of event:
ENABLE.video.VIDEOEVENT_STREAM_STARTED
ENABLE.video.VIDEOEVENT_START_OF_STREAM
ENABLE.video.VIDEOEVENT_END_OF_STREAM
ENABLE.video.VIDEOEVENT_PLAYBACK_STOP
ENABLE.video.VIDEOEVENT_ERROR
ENABLE.video.VIDEOEVENT_DECRYPTION_SUCCESS
ENABLE.video.VIDEOEVENT_DECRYPTION_FAIL
ENABLE.video.VIDEOEVENT_PLAYBACK_LOW_BUFFER
ENABLE.video.VIDEOEVENT_PLAYBACK_BUFFER_READY