1.2.0 Player

new Player ()

Create instance of player.
In this version, maximum of 4 players are supported.

Classes

Player

Methods

static Player.getCapability () {Object}

Get Player Capability.

Since:
  • 1.0.0
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.

static Player.getInstance (id) { Player }

Get Player with player ID. It will create a new player if the requested player ID is not created before.

Name Type Description
id Number

The player ID of the player

Since:
  • 1.0.0
Returns:
Type Description
Player A instance of player with the specified player ID

static Player.releaseAll () {object}

Release all player instances created in current session.

Since:
  • 1.0.0
Returns:
Name Type Description
object object
Name Type Description
status_code String ENABLE.status.SUCCESS

getAudioRendering () {Object}

Get the audio rendering status.

Since:
  • 1.0.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS
result boolean true , audio rendering is enabled, false , audio rendering is disabled

getAudioStats () {Object}

Get Audio Decoder statistics

Since:
  • 1.0.0
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.

Since:
  • 1.0.0
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.

Since:
  • 1.0.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR
result Boolean true or false

getDuration () {Object}

Gets the duration of the current playback.

Since:
  • 1.0.0
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.

Since:
  • 1.0.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.ERROR
result Boolean true or false

getOsdResolution () {Object}

Get OSD resolution available for positioning the video window.

Since:
  • 1.0.0
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.

getPlayerId () {object}

Get player ID of current player instance

Since:
  • 1.0.0
Returns:
Name Type Description
object object
Name Type Description
object.status_code String
id Number The id of the player

getPlayPosition () {Object}

Gets the current playback position.

Since:
  • 1.0.0
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.

Since:
  • 1.0.0
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.

Since:
  • 1.0.0
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.

Since:
  • 1.0.0
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.

Since:
  • 1.0.0
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.

Since:
  • 1.0.0
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

Since:
  • 1.0.0
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.

Since:
  • 1.0.0
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.

Since:
  • 1.0.0
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)

getZOrder () {Object}

Get the Z Order of the players. The z-index of webview layer is 100. By default, the first player contains z-index of players start with 0. The z-index of the new created player will be 1 value higher than the current highest player's z-index value.

Since:
  • 1.0.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.INVALID_ARGUMENT for zIndex using negative number
result Number The z-index value

isLiveStream () {Object}

Returns true if current source is live.

Since:
  • 1.0.0
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.

Since:
  • 1.0.0
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.
A ENABLE.player.PLAYEREVENT_RELEASING event will be emitted.
All the players created in the same session will be released automatically at the end of session ( beforeunload event). However, you could release manually release the player to release the resources

Since:
  • 1.0.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS

reset () {Object}

Resets the player to its uninitialized state.

Since:
  • 1.0.0
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.

Since:
  • 1.0.0
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

setAudioRendering (enable) {Object}

Set the audio rendering of the players. This API is different from Player#setMute and Player#setVolume . It disables the audio track to reduce the CPU usage. Only one player is allowed for playing audio at a time. By enabling one player audio rendering, the audio rendering for others player instances are disabled automatically. It is also possible to disable the audio rendering for all player instances by setting this API to false . Audio rendering is enabled automatically when there are no player instance during player instance creation. Otherwise, it is disable by default.

Name Type Description
enable boolean

true for enabling audio rendering for current player, false for disabling audio rendering

Since:
  • 1.0.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS

setAudioTrack (id) {Object}

Select an audio track

Name Type Description
id Number

Track id of audio

Since:
  • 1.0.0
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 or false to unblank

Since:
  • 1.0.0
Returns:
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. Pass null 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.

Since:
  • 1.0.0
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 or false to unmute

Since:
  • 1.0.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.INVALID_ARGUMENT

setResizeMode (mode) {Object}

Set the resize mode of video

Name Type Description
mode Number

The resize mode of video,
ENABLE.preference.RESIZE_MODE_FIT ,
ENABLE.preference.RESIZE_MODE_FILL , or
ENABLE.preference.RESIZE_MODE_ZOOM

Since:
  • 1.0.0
Returns:
Name Type Description
object Object
Name Type Description
status_code Object ENABLE.status.SUCCESS or ENABLE.status.INVALID_ARGUMENT

setSource (url, config ) {Object}

Set source of player

ABR (DASH and HLS) : https://{host}:{port}/{playlist_path}

Play a ABR stream

var videoControl = new ENABLE.player();
videoControl.setSource("http://www.aminocom.com/videos/playlist.mpd");
// or
videoControl.setSource("http://www.aminocom.com/videos/playlist.m3u8");

Play a widevine encrypted DASH stream

var config = {encryption_type: "com.widevine.alpha", encrypting_server: "http://demo.aminocom.com/license"};
videoControl.setSource("http://www.aminocom.com/videos/sample_enc.mpd", config);

Play a 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.setSource("http://www.aminocom.com/videos/sample_enc.mpd", config);

Play a 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.setSource("http://www.aminocom.com/videos/sample_enc.mpd", config);
HTTP Progressive : https://{host}:{port}/{file_path}
videoControl.setSource("http://192.168.1.1/abc.mp4");
Unicast : udp://{address}:{port}?prog_id=[number]&disable_av_sync=[boolean]
videoControl.setSource("udp://0.0.0.0:8110");
Multicast : udp://{address}:{port}?prog_id=[number]&disable_av_sync=[boolean]

Play a multicast video

videoControl.setSource("udp://233.22.133.100:8110");

Play a multicast video with program id specified and AV sync disabled

videoControl.setSource("udp://233.22.133.100:8110?prog_id=1&disable_av_sync=true");
RTSP : rtsp://{server}/{asset}
videoControl.setSource("rtsp://www.domain.com:554/stream.ts");
SRT : srt://{address}:{port}?streamid=[number]&password=[string]
videoControl.setSource("srt://1.2.3.4:8888");
videoControl.setSource("srt://1.2.3.4:8888?streamid=3&password=aaaa");
IGMPv3 : igmpv3://{address}:{port}?mcast=[asm|ssm_include|ssm_exclude]&src_addr=[address]
videoControl.setSource("igmpv3://192.168.1.1:8110?mcast=asm");
videoControl.setSource("igmpv3://192.168.1.1:8110?mcast=ssm_include&src_addr=192.168.1.30&src_addr=192.168.1.32");
videoControl.setSource("igmpv3://192.168.1.1:8110?mcast=ssm_exclude&src_addr=192.168.1.30&src_addr=192.168.1.32");
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 or ENABLE.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.

Since:
  • 1.1.0
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

Since:
  • 1.0.0
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 screen

Name 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.

Since:
  • 1.0.0
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 270
Video Rotation only supports when the number of video player instances is not more than 2. The rotation behaviour is undefined when there are more than 2 video player instances. The undefined behaviour could only be removed with device reboot with new APK installation.

Name 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

Since:
  • 1.0.0
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)

Since:
  • 1.0.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.INVALID_ARGUMENT

setZOrder (zIndex) {Object}

Set the Z Order of the players. The z-index of webview layer is 100. By default, the first player contains z-index of players start with 0. The z-index of the new created player will be 1 value higher than the current highest player's z-index value.

Name Type Description
zIndex Number

The z-index of the player. The number should be non-negative number.

Since:
  • 1.0.0
Returns:
Name Type Description
object Object
Name Type Description
status_code String ENABLE.status.SUCCESS or
ENABLE.status.INVALID_ARGUMENT for zIndex using negative number

stop () {Object}

Stops playback after playback has been started or paused.

Since:
  • 1.0.0
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.

Since:
  • 1.0.0
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
ENABLE.player.PLAYEREVENT_RELEASING