Class

Media

Media()

Constructor

# new Media()

Media class which is managed by mediaManager Loads and plays media (by calling underlying media player).

Methods

# deinit()

Deinit the media instance to be ready for dispose and GC

# fastForward(paramopt)

To fastForward the media

Parameters:
Name Type Attributes Description
param Object | Number <optional>

the fastForward param option or fastForward second

multipleFactor Number <optional>

The multiple of increase in jump distance for each fastForward

delaySecond Number <optional>

The second to be delayed before perform the actual fastForward

progressiveCap Number <optional>

The maximum amount of second in each increase

# getAudioTrackAttribute(id, attribute, defaultValue) → {Promise.<String>}

Get the audio track attribute.

Parameters:
Name Type Description
id String

the target track id

attribute String

the attribute key

defaultValue String

the defaultValue

Promise.

Promise.<String>

# getAudioTracks() → {Promise.<Object>}

Get the available audio tracks.

Promise.

Promise.<Object>

# getBitrates() → {interfaces/Player~MediaBitrates}

To get the media bitrates

the bitrate information

interfaces/Player~MediaBitrates

# getCurrentAudioTrack() → {Promise.<?{(Object|Integer)}>}

Get the current audio track.

To Do:
  • All Strategies should return the same type.

Promise.

Promise.<?{(Object|Integer)}>

# getCurrentSubtitle() → {Promise.<Subtitle>}

Get the current subtitle.

Promise.

Promise.<Subtitle>

# getCurrentTime() → {Number}

To get the media current time

the player current time

Number

# getDuration() → {Number}

To get the media duration

the duration

Number

# getId() → {String}

To get the media id

The id of the media

String

# getOption() → {Object}

Get the current media option

the media option

Object

# getPlaybackSpeed() → {Number}

To get the media playback speed

the playback speed

Number

# getPlayer() → {Object}

To get the player instance. Dangerous

Deprecated:
  • Yes

Player Instance

Object

# getPlayerId() → {String}

To get the player id associated with media instance

the id path of the player

String

# getPlayerObject() → {Object}

To get the player object from the player instance. Dangerous

Player Object

Object

# getState() → {constant/Media.STATE}

To get the current state

the current state

constant/Media.STATE

# async getSubtitles() → {Promise.<Array.<Subtitle>>}

Get the info for all subtitle.

Promise.

Promise.<Array.<Subtitle>>

# getTargetSkipTime() → {Number}

To get the target time when progressive skipping

the targetSkip time when skipping

Number

# getURL() → {String}

Get the current media URL

the media URL

String

# getVideoSize() → {interfaces/Player~VideoSize}

To get the video size

the video size

interfaces/Player~VideoSize

# hideSubtitle() → (nullable) {Promise}

Hide the subtitle that is being displayed.

Promise.

Promise

# isPreloadable(url, option) → {Boolean}

Check and see if player support preload with provided config

Parameters:
Name Type Description
url String

the media url

option PlayerOptions

the load option

preloadable player or not

Boolean

# isSinglePlayerOnly() → {Boolean}

To get the playerKlass attribute, does it allow other player instance linked

single player or not

Boolean

# isState(state) → {Boolean}

To check the current state

Parameters:
Name Type Description
state constant/Media.STATE

the expected state

True if it is the expected state

Boolean

# isSuspended() → {Boolean}

Return if it is in suspended state

suspended state

Boolean

# async load(url, option)

To load the media

Parameters:
Name Type Description
url String

the media url

option PlayerOptions

the load option

# pause()

To pause the media

# async play(second)

To play the media

Parameters:
Name Type Description
second Number

the play second

# preload(url, option)

Preload media

Parameters:
Name Type Description
url String

the media url

option PlayerOptions

the load option

# async prepare()

Prepare the player

# prepareLoadOption(url, option)

Prepare load url and option so it is not necessary to set in load function. It will be used in media.preload function or in mediaManager.preloadMedia function. It will be overwritten if called again.

Parameters:
Name Type Description
url String

the media url

option PlayerOptions

the load option

# restore(option)

To restore the media

Parameters:
Name Type Description
option Object

extra option to pass to restore object

# resume(second)

To seek the media

Parameters:
Name Type Description
second Number

the target seek position

# rewind(paramopt)

To rewind the media

Parameters:
Name Type Attributes Description
param Object | Number <optional>

the rewind param option or rewind second

multipleFactor Number <optional>

The multiple of increase in jump distance for each rewind

delaySecond Number <optional>

The second to be delayed before perform the actual rewind

progressiveCap Number <optional>

The maximum amount of second in each increase

# setAudioTrack(id) → {Promise}

Set the current audio track to the one specified.

Parameters:
Name Type Description
id String

the audio track id

Promise.

Promise

# setFullscreen()

To set the video fullscreen

# setVideoDisplayMode(mode) → {Boolean}

Set the video display mode

Parameters:
Name Type Description
mode VIDEO_DISPLAY_MODE

Video Display Mode constant/Media#VIDEO_DISPLAY_MODE.

Generic Error if no player is found

True if set, false if not

Boolean

# setVideoSizeAndPosition(sizeAndPosition)

To set the video size and position

Parameters:
Name Type Description
sizeAndPosition Object

the video size and position object

width Number

the video width

height Number

the video height

left Number

the video left position

top Number

the video top position

# showSubtitle(id) → (nullable) {Promise}

Show the subtitle specified by the ID.

Parameters:
Name Type Description
id String

the subtitle id

Promise.

Promise

# speed(speed)

To speed the media

Parameters:
Name Type Description
speed Number

the speed rate

# stop()

To stop the media

# suspend(forceReset)

To suspend the media

Parameters:
Name Type Description
forceReset Boolean

boolean to force reset player when suspending

# unload()

Unload media to a clean status to be ready for next load

Type Definitions

Object

# PlayerOptions

Player Options object

Properties:
Name Type Description
drm String

DRM type. See constant/Media#DRM.

drmURL String

DRM license URL

drmHttpHeader String

Http Header for DRM License Server Request

protocol String

Protocol type. See constant/Media.

guessStreamingProtocol function

Custom function to guess the stream protocol based on the url and the options. See constant/Media#PROTOCOL.

Subtitle Array.<SubtitleObject>

Subtitles array object