Index
Player Initialize/Uninitialize and load Media
Initialize | Uninitialize | Load Media Source
Playback Control
Play | Pause | Seek | Forward | Rewind
Set Player Parameters
setQuality | setAudioTrack |setSubtitle
Get Player Parameters
getPlaybackState | getPlaybackSpeed
getVolume | getCurrentTime | getTotalDuration
getQualities | getCurrentQuality
getAudioTracks | getCurrentAudioTrack
getSubtitles | getCurrentSubtitle
Player View
setViewMode | switchControlMode
initialize
Initialize a player instance.
player.UniPlayer(target, config)
Parameters
const target = 'playerId'
const config =
{
license: '',
validationHost: '',
title: '',
autoplay: true,
metadata: {
share: [],
description: '',
watermark: {
position: '',
image_url: '',
text: ''
}
},
ui: {
locale: '',
uiMode: ''
},
source,
}
const source = [
{
type: 'application/dash+xml',
src: '',
drm: {
widevine: {
licenseUri: ‘’,
headers: {},
}
},{
type: 'application/x-mpegurl',
src: '',
drm: {
fairplay: {
licenseUri: '',
certificateUri: '',
headers: {},
certificateHeaders: {},
}
},
}
])
since: 2.1.0
release
Destroy the player and removes all inserted HTML elements and event handlers.
player.release()
since: 2.1.0
load
Sets a new video source and returns a promise which resolves to the player.
player.load(SourceConfig)
Parameters
SourceConfig =
{
type: 'vod | live',
src: '',
drm: {
fairplay: {
licenseUri: '',
certificateUri: '',
}
},
}
since: 2.1.0
Playback Control
play
Starts playback or resumes after being paused. No need to call it if the player is set autoplay as true during initialize player. Has no effect if the player is already playing.
player.play()
since: 2.1.0
pause
Pauses the video if it is playing. Has no effect if the player is already paused.
player.pause()
since: 2.1.0
seek
Seeks to the given playback time specified by the parameter time in seconds. Must not be greater than the total duration of the video. Has no effect when watching a live stream as seeking is not possible.
player.seek(seconds)
Parameters
seconds: float
Note:
As seeking to end the video may cause glitches and no response to replay. We set the duration - 0.7 in order to prevent these problems.
Example:
play a video whose duration is 120s
player.seek(10) -> player seek 10s
player.seek(120) -> player seek 119.3s
since: 2.1.0
forward
Forward to the given playback time specified by the parameter time in seconds. Must not be greater than the total duration of the video.
player.forward(seconds)
Parameters
seconds: float
since: 2.1.0
rewind
Rewind to the given playback time specified by the parameter time in seconds. Must not be greater than the total duration of the video.
player.rewind(seconds)
Parameters
seconds: float
since: 2.1.0
getPlaybackState
Returns playback state.
player.getPlaybackState()
Returns
State = string
init: player is initialized
loading: source file is loading
paused: playback is paused
playing: playback is playing
buffering: playback is buffering
ended: playback is ended
since: 2.1.0
Get/Set Player Information
getVolume
Returns the player’s volume between 0.0 (silent) and 1.0 (max volume) by floating type.
player.getVolume()
Returns
volume: float (0.0 ~ 1.0)
since: 2.1.0
setVolume
Sets the player’s volume in the range of 0.0 (silent) to 1.0 (max volume). Unmutes a muted player.
player.setVolume(volume)
Parameters
volume: float (0.0 ~ 1.0)
since: 2.1.0
mute
Mutes the player if an audio track is available. Has no effect if the player is already muted.
player.mute()
since: 2.1.0
unmute
Unmutes the player if muted.
player.unmute()
since: 2.1.0
getCurrentTime
Returns the current playback time in milliseconds of the video.
player.currentTime()
Returns
timeInterval: float
since: 2.1.0
getTotalDuration
Returns the total duration in milliseconds of the current video. There's no reference value if it's a live stream.
player.getDuration()
Returns
timeInterval: float
since: 2.1.0
getQualities
Returns an array containing all available video qualities the player can adapt between.
player.getQualities()
Returns
quality = [{
width,
height,
bitrate,
framerate
}]
since: 2.1.0
getCurrentQuality
Returns the currently selected video quality, if the user manually selected one. In this case it returns one of the elements of getQualities.
player.getCurrentQuality()
Returns
quality = [{
width,
height,
bitrate,
framerate
}]
since: 2.1.0
setQuality
Manually sets the video stream to a fixed quality, e.g. height range, specified bitrate or null (means auto resets to dynamic switching). A list can be retrieved by calling getQualities.
player.setQuality(quality)
Parameters
quality = [{maxHeight, minHeight}]
quality = [{maxHeight: 720}]
quality = null
since: 2.1.0
getAudioTracks
Returns an array of all available audio tracks.
player.getAudioTracks()
Returns
language = [{
language: 'en'},{
language: 'zh-TW'}
]
since: 2.1.0
getCurrentAudioTrack
Returns the currently selected audio track, if the user manually selected one. In this case it returns one of the elements of getAudioTracks.
player.getCurrentAudioTrack()
Returns
language = [{language: 'en'}]
since: 2.1.0
setAudioTrack
Manually sets the audio track to a specified language. Available tracks can be retrieved with getAudioTracks.
player.setAudioTrack(language)
Parameters
language = [{language: 'en'}]
since: 2.1.0
getSubtitles
Returns an array of all available subtitles.
player.getSubtitles()
Returns
language = [{
language: 'en'},{
language: 'zh-TW'}
]
since: 2.1.0
getCurrentSubtitle
Returns the currently selected subtitle, if the user manually selected one. In this case it returns one of the elements of getSubtitles.
player.getCurrentSubtitle()
Returns
language = [{language: 'en'}]
since: 2.1.0
setSubtitle
Manually sets the subtitle to a specified language or turn-off. Available subtitles can be retrieved with getSubtitles.
player.setSubtitle(language)
Parameters
language = [{language: 'en'}]
language = ['off']
since: 2.1.0
getPlaybackSpeed
Returns the current playback speed of the player. 1 is the default playback speed, values between 0 and 1 refer to slow motion and values greater than 1 refer to fast forward. Values less or equal zero are ignored.
player.gerPlaybackSpeed()
Returns
speed: number
since: 2.1.0
setPlaybackSpeed
Sets the playback speed of the player. Fast forward as well as slow motion is supported. Slow motion is used by values between 0 and 1, and fast forward by values greater than 1.
player.setPlaybackSpeed(speed)
Parameters
speed: number
since: 2.1.0
Player View
setViewMode
Sets the player to a particular ViewMode.
player.setViewMode(viewMode)
Parameters
viewMode: fullscreen | inline
since: 2.1.0
switchControlMode
Sets the UI state automatically. Shows controller when the user interacts with and did when no interaction in 3 seconds. The controller includes a progress bar, seek function, title, back button, play, pause, rewind, thumbnail, and so on.
player.switchControlMode(viewMode)
Parameters
viewMode: AUTO | SHOW | HIDE
since: 2.1.0
setPlayerLanguage
Sets player language without using browser language.
kksPlayer(target, config)
Parameters
const config = {
ui: {
locale: 'en' | 'ja' | 'zh-TW'
}
}
since: 2.1.0