# Playback API
# UZ : object
Namespace UZ is an object
Kind: global namespace
- UZ :
object
- instance
- .ERROR :
object
- .RESTRICTED :
string
- .MEDIA_INFO_IS_INCORRECT :
string
- .LIVE_INFO_IS_INCORRECT :
string
- .ABORTED_THE_MEDIA_PLAYBACK :
string
- .THE_MEDIA_DOWNLOAD_TO_FAIL_PART_WAY :
string
- .THE_MEDIA_COUND_NOT_BE_LOADED :
string
- .THE_MEDIA_PLAYBACK_WAS_ABORTED :
string
- .NO_COMPATIBLE_SOURCE :
string
- .THE_MEDIA_IS_ENCRYPTED :
string
- .RESTRICTED :
- .ERROR :
- static
- .Player
- new Player(id)
- .iframe :
Element
- .addRemoteTextTrack(options) ⇒
HTMLTrackElement
- .aspectRatio([ratio]) ⇒
string
|undefined
- .autoplay([value]) ⇒
string
- .bufferedPercent() ⇒
number
- .canPlayType(type) ⇒
string
- .controls([bool]) ⇒
boolean
- .currentLevel([level]) ⇒
number
|undefined
- .currentTime([time]) ⇒
number
|undefined
- .dispose()
- .duration() ⇒
number
|undefined
- .error() ⇒
MediaError
|null
- .enterFullWindow()
- .exitFullscreen()
- .exitFullWindow()
- .height([value]) ⇒
number
- .isFullscreen([isFS]) ⇒
boolean
- .language([code]) ⇒
string
- .load()
- .loop([value]) ⇒
string
- .muted([muted]) ⇒
boolean
- .off(type, fn)
- .on(type, fn)
- .pause() ⇒
Player
- .paused() ⇒
boolean
- .play() ⇒
Promise
|undefined
- .playbackRate([rate]) ⇒
number
- .playsinline([value]) ⇒
string
|Player
- .poster([src]) ⇒
string
- .preload([value]) ⇒
string
- .qualities() ⇒
array
- .remainingTime() ⇒
number
- .requestFullscreen()
- .reset()
- .src([source]) ⇒
string
|undefined
- .volume([percentAsDecimal]) ⇒
number
- .width([value]) ⇒
number
- .Player
- instance
# uZ.ERROR : object
The player playback state
Kind: instance namespace of UZ
- .ERROR :
object
- .RESTRICTED :
string
- .MEDIA_INFO_IS_INCORRECT :
string
- .LIVE_INFO_IS_INCORRECT :
string
- .ABORTED_THE_MEDIA_PLAYBACK :
string
- .THE_MEDIA_DOWNLOAD_TO_FAIL_PART_WAY :
string
- .THE_MEDIA_COUND_NOT_BE_LOADED :
string
- .THE_MEDIA_PLAYBACK_WAS_ABORTED :
string
- .NO_COMPATIBLE_SOURCE :
string
- .THE_MEDIA_IS_ENCRYPTED :
string
- .RESTRICTED :
# ERROR.RESTRICTED : string
Message: The video you are trying to watch cannot be viewed because of domain restrictions
Kind: static constant of ERROR
# ERROR.MEDIA_INFO_IS_INCORRECT : string
Message: The media stream could not be loaded, because the media info is incorrect.
Kind: static constant of ERROR
# ERROR.LIVE_INFO_IS_INCORRECT : string
Message: The live stream could not be loaded, because the live info is incorrect.
Kind: static constant of ERROR
# ERROR.ABORTED_THE_MEDIA_PLAYBACK : string
Message: You aborted the media playback
Kind: static constant of ERROR
# ERROR.THE_MEDIA_DOWNLOAD_TO_FAIL_PART_WAY : string
Message: A network error caused the media download to fail part-way.
Kind: static constant of ERROR
# ERROR.THE_MEDIA_COUND_NOT_BE_LOADED : string
Message: The media could not be loaded, either because the server or network failed or because the format is not supported.
Kind: static constant of ERROR
# ERROR.THE_MEDIA_PLAYBACK_WAS_ABORTED : string
Message: The media playback was aborted due to a corruption problem or because the media used features your browser did not support.
Kind: static constant of ERROR
# ERROR.NO_COMPATIBLE_SOURCE : string
Message: No compatible source was found for this media.
Kind: static constant of ERROR
# ERROR.THE_MEDIA_IS_ENCRYPTED : string
Message: The media is encrypted and we do not have the keys to decrypt it.
Kind: static constant of ERROR
# UZ.Player
Kind: static class of UZ
- .Player
- new Player(id)
- .iframe :
Element
- .addRemoteTextTrack(options) ⇒
HTMLTrackElement
- .aspectRatio([ratio]) ⇒
string
|undefined
- .autoplay([value]) ⇒
string
- .bufferedPercent() ⇒
number
- .canPlayType(type) ⇒
string
- .controls([bool]) ⇒
boolean
- .currentLevel([level]) ⇒
number
|undefined
- .currentTime([time]) ⇒
number
|undefined
- .dispose()
- .duration() ⇒
number
|undefined
- .error() ⇒
MediaError
|null
- .enterFullWindow()
- .exitFullscreen()
- .exitFullWindow()
- .height([value]) ⇒
number
- .isFullscreen([isFS]) ⇒
boolean
- .language([code]) ⇒
string
- .load()
- .loop([value]) ⇒
string
- .muted([muted]) ⇒
boolean
- .off(type, fn)
- .on(type, fn)
- .pause() ⇒
Player
- .paused() ⇒
boolean
- .play() ⇒
Promise
|undefined
- .playbackRate([rate]) ⇒
number
- .playsinline([value]) ⇒
string
|Player
- .poster([src]) ⇒
string
- .preload([value]) ⇒
string
- .qualities() ⇒
array
- .remainingTime() ⇒
number
- .requestFullscreen()
- .reset()
- .src([source]) ⇒
string
|undefined
- .volume([percentAsDecimal]) ⇒
number
- .width([value]) ⇒
number
# new Player(id)
Create an player by id of iframe
Returns: Player
- Returns a Player
object
Param | Type | Description |
---|---|---|
id | String | Id of iframe tag. |
# player.iframe : Element
The iframe DOM element used for init options
Kind: instance property of Player
# player.addRemoteTextTrack(options) ⇒ HTMLTrackElement
Create an emulated TextTrack for use by addRemoteTextTrack
This is intended to be overridden by classes that inherit from Tech in order to create native or custom TextTracks.
Kind: instance method of Player
Returns: HTMLTrackElement
- The track element that gets created.
Param | Type | Description |
---|---|---|
options | Object | The object should contain the options to initialize the TextTrack with. |
[options.kind] | string | TextTrack kind (subtitles, captions, descriptions, chapters, or metadata). |
[options.label] | string | Label to identify the text track |
[options.language] | string | Two letter language abbreviation. |
# player.aspectRatio([ratio]) ⇒ string
| undefined
A getter/setter for the Player
's aspect ratio.
Kind: instance method of Player
Returns: string
| undefined
- - The current aspect ratio of the Player
when getting.
- undefined when setting
Param | Type | Description |
---|---|---|
[ratio] | string | The value to set the `Player's aspect ratio to. |
# player.autoplay([value]) ⇒ string
Get or set the autoplay attribute.
Kind: instance method of Player
Returns: string
- The current value of autoplay when getting
Param | Type | Description |
---|---|---|
[value] | boolean | - true means that we should autoplay - false means that we should not autoplay |
# player.bufferedPercent() ⇒ number
Get the percent (as a decimal) of the video that's been downloaded
Kind: instance method of Player
Returns: number
- 0 means none, 1 means all.
# player.canPlayType(type) ⇒ string
Check whether the player can play a given mimetype
Kind: instance method of Player
Returns: string
- 'probably', 'maybe', or '' (empty string)
See: https://www.w3.org/TR/2011/WD-html5-20110113/video.html#dom-navigator-canplaytype
Param | Type | Description |
---|---|---|
type | string | The mimetype to check |
# player.controls([bool]) ⇒ boolean
Get or set whether or not the controls are showing.
Kind: instance method of Player
Returns: boolean
- The current value of controls when getting
Emits: Player#event:controlsenabled
Param | Type | Description |
---|---|---|
[bool] | boolean | - true to turn controls on - false to turn controls off |
# player.currentLevel([level]) ⇒ number
| undefined
Get/Set the level of video quality
Kind: instance method of Player
Returns: number
| undefined
- returns the current level of video quality when getting
Param | Type | Description |
---|---|---|
[level] | number | Level to change |
# player.currentTime([time]) ⇒ number
| undefined
Get/Set the current time
Kind: instance method of Player
Returns: number
| undefined
- returns the current time when getting
Param | Type | Description |
---|---|---|
[time] | string | Time for seek to |
# player.dispose()
Turn off all event polyfills, clear the Player
s properties
Kind: instance method of Player
Emits: Player#event:dispose
# player.duration() ⇒ number
| undefined
Get the duration
Kind: instance method of Player
Returns: number
| undefined
- returns the duration
# player.error() ⇒ MediaError
| null
Get an error on the player.
Kind: instance method of Player
Returns: MediaError
| null
- The current error object on the player, or null if there isn't one.
# player.enterFullWindow()
When fullscreen isn't supported we can stretch the video container to as wide as the browser will let us.
Kind: instance method of Player
Emits: Player#event:enterFullWindow
# player.exitFullscreen()
Return the video to its normal size after having been in full screen mode
Kind: instance method of Player
Emits: Player#event:fullscreenchange
# player.exitFullWindow()
Exit full window
Kind: instance method of Player
Emits: Player#event:exitFullWindow
# player.height([value]) ⇒ number
A getter/setter for the Player
's height. Returns the player's configured value.
To get the current height use currentheight()
.
Kind: instance method of Player
Returns: number
- The current height of the Player
when getting.
Param | Type | Description |
---|---|---|
[value] | number | The value to set the Player 's heigth to. |
# player.isFullscreen([isFS]) ⇒ boolean
Check if the player is in fullscreen mode or tell the player that it is or is not in fullscreen mode.
NOTE: As of the latest HTML5 spec, isFullscreen is no longer an official property and instead document.fullscreenElement is used. But isFullscreen is still a valuable property for internal player workings.
Kind: instance method of Player
Returns: boolean
- - true if fullscreen is on and getting
- false if fullscreen is off and getting
Param | Type | Description |
---|---|---|
[isFS] | boolean | Set the players current fullscreen state |
# player.language([code]) ⇒ string
The player's language code NOTE: The language should be set in the player options if you want the the controls to be built with a specific language. Changing the lanugage later will not update controls text.
Kind: instance method of Player
Returns: string
- The current language code when getting
Param | Type | Description |
---|---|---|
[code] | string | the language code to set the player to |
# player.load()
Begin loading the src data.
Kind: instance method of Player
# player.loop([value]) ⇒ string
Get or set the loop attribute on the video element.
Kind: instance method of Player
Returns: string
- The current value of loop when getting
Param | Type | Description |
---|---|---|
[value] | boolean | - true means that we should loop the video - false means that we should not loop the video |
# player.muted([muted]) ⇒ boolean
Get the current muted state, or turn mute on or off
Kind: instance method of Player
Returns: boolean
- - true if mute is on and getting
- false if mute is off and getting
Param | Type | Description |
---|---|---|
[muted] | boolean | - true to mute - false to unmute |
# player.off(type, fn)
Removes an event listener
for a specific event from an instance of Player
.
This makes it so that the event listener
will no longer get called when the
named event happens.
Kind: instance method of Player
Param | Type | Description |
---|---|---|
type | string | Array.<string> | An event name or an array of event names. |
fn | EventListener | The function to remove. |
# player.on(type, fn)
Adds an event listener
to an instance of an Player
. An event listener
is a
function that will get called when an event with a certain name gets triggered.
Kind: instance method of Player
See
Param | Type | Description |
---|---|---|
type | string | Array.<string> | An event name or an array of event names. |
fn | EventListener | The function to call. |
# player.pause() ⇒ Player
Pause the video playback
Kind: instance method of Player
Returns: Player
- A reference to the player object this function was called on
# player.paused() ⇒ boolean
Check if the player is paused or has yet to play
Kind: instance method of Player
Returns: boolean
- - false: if the media is currently playing
- true: if media is not currently playing
# player.play() ⇒ Promise
| undefined
start media playback
Kind: instance method of Player
Returns: Promise
| undefined
- Returns a Promise
if the browser returns one, for most browsers this will
return undefined.
# player.playbackRate([rate]) ⇒ number
Gets or sets the current playback rate. A playback rate of 1.0 represents normal speed and 0.5 would indicate half-speed playback, for instance.
Kind: instance method of Player
Returns: number
- The current playback rate when getting or 1.0
See: https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-playbackrate
Param | Type | Description |
---|---|---|
[rate] | number | New playback rate to set. |
# player.playsinline([value]) ⇒ string
| Player
Set or unset the playsinline attribute. Playsinline tells the browser that non-fullscreen playback is preferred.
Kind: instance method of Player
Returns: string
| Player
- - the current value of playsinline
- the player when setting
See: Spec
Param | Type | Description |
---|---|---|
[value] | boolean | - true means that we should try to play inline by default - false means that we should use the browser's default playback mode, which in most cases is inline. iOS Safari is a notable exception and plays fullscreen by default. |
# player.poster([src]) ⇒ string
Get or set the poster image source url
Kind: instance method of Player
Returns: string
- The current value of poster when getting
Emits: Player#event:posterchange
Param | Type | Description |
---|---|---|
[src] | string | Poster image source URL |
# player.preload([value]) ⇒ string
Get or set the preload attribute
Kind: instance method of Player
Returns: string
- The preload attribute value when getting
Param | Type | Description |
---|---|---|
[value] | boolean | - true means that we should preload - false maens that we should not preload |
# player.qualities() ⇒ array
Get the video qualites
Kind: instance method of Player
Returns: array
- - Array of object which have key label
to display
# player.remainingTime() ⇒ number
Calculates how much time is left in the video. Not part of the native video API.
Kind: instance method of Player
Returns: number
- The time remaining in seconds
# player.requestFullscreen()
Increase the size of the video to full screen In some browsers, full screen is not supported natively, so it enters "full window mode", where the video fills the browser window. In browsers and devices that support native full screen, sometimes the browser's default controls will be shown, and not the Video.js custom skin. This includes most mobile devices (iOS, Android) and older versions of Safari.
Kind: instance method of Player
Emits: Player#event:fullscreenchange
# player.reset()
Reset the player. Loads the first tech in the techOrder,
and calls reset
on the tech`.
Kind: instance method of Player
# player.src([source]) ⇒ string
| undefined
Get or set the video source.
Kind: instance method of Player
Returns: string
| undefined
- If the source
argument is missing, returns the current source
URL. Otherwise, returns nothing/undefined.
Param | Type | Description |
---|---|---|
[source] | Tech~SourceObject | Array.<Tech~SourceObject> | string | A SourceObject, an array of SourceObjects, or a string referencing a URL to a media source. It is highly recommended that an object or array of objects is used here, so that source selection algorithms can take the type into account. If not provided, this method acts as a getter. |
# player.volume([percentAsDecimal]) ⇒ number
Get or set the current volume of the media
Kind: instance method of Player
Returns: number
- The current volume as a percent when getting
Param | Type | Description |
---|---|---|
[percentAsDecimal] | number | The new volume as a decimal percent: - 0 is muted/0%/off - 1.0 is 100%/full - 0.5 is half volume or 50% |
# player.width([value]) ⇒ number
A getter/setter for the Player
's width. Returns the player's configured value.
To get the current width use currentWidth()
.
Kind: instance method of Player
Returns: number
- The current width of the Player
when getting.
Param | Type | Description |
---|---|---|
[value] | number | The value to set the Player 's width to. |
Playback API on Github
Playback API on Github
# UZPlayer
Kind: global class
- UZPlayer
- new UZPlayer(selector, options)
- .PlaybackState :
object
- .initVOD(entityId, callback)
- .initLive(entityId, entityId, entityId, callback)
- .setAutoPlay(value)
- .getAutoPlay() ⇒
boolean
- .setCurrentTime([time])
- .getCurrentTime() ⇒
number
- .destroy()
- .getDuration() ⇒
number
- .setFullscreen(fullscreen)
- .toggleFullscreen()
- .getFullscreen() ⇒
boolean
- .setMute(muted)
- .toggleMute()
- .pause()
- .play()
- .setVolume([percentAsDecimal])
- .getVolume() ⇒
number
- .setPlayPercentage([percentage])
- .getPlayPercentage() ⇒
number
- .getPlaybackState() ⇒
PlaybackState
- .bufferedPercent() ⇒
number
- .qualities() ⇒
array
- .getCurrentLevel() ⇒
number
|undefined
- .setCurrentLevel([level])
- .onEnded(callback)
- .onError(callback)
- .onFullscreen(callback)
- .onLoad(callback)
- .onPause(callback)
- .onPlay(callback)
- .onPlaybackState(callback)
- .onVolume(callback)
- .onWaiting(callback)
- .onQualities(callback)
- .onLevel(callback)
# new UZPlayer(selector, options)
Create an player by selector of element
Returns: UZPlayer
- Returns a UZPlayer
object
Param | Type | Description |
---|---|---|
selector | string | Selector of element tag. |
options | object | Configuration |
# uzPlayer.PlaybackState : object
The player playback state
Kind: instance namespace of UZPlayer
- .PlaybackState :
object
# PlaybackState.NONE : string
Player is not created
Kind: static constant of PlaybackState
# PlaybackState.IDLE : string
Player is created but not prepared
Kind: static constant of PlaybackState
# PlaybackState.READY : string
Player is ready to play media
Kind: static constant of PlaybackState
# PlaybackState.PLAYING : string
Player is playing media
Kind: static constant of PlaybackState
# PlaybackState.PAUSED : string
Player is paused
Kind: static constant of PlaybackState
# PlaybackState.WAITING : string
Player is waiting (buffering)
Kind: static constant of PlaybackState
# uzPlayer.initVOD(entityId, callback)
Call initialize VOD.
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
entityId | string | The entityId |
callback | function | The callback function |
# uzPlayer.initLive(entityId, entityId, entityId, callback)
Call initialize VOD.
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
entityId | string | The entityId |
entityId | string | The streamName |
entityId | string | The region |
callback | function | The callback function |
# uzPlayer.setAutoPlay(value)
Set the autoplay attribute.
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
value | boolean | The new value: - true means that we should autoplay - false means that we should not autoplay |
# uzPlayer.getAutoPlay() ⇒ boolean
Get the autoplay attribute.
Kind: instance method of UZPlayer
Returns: boolean
- The current value of autoplay when getting
# uzPlayer.setCurrentTime([time])
Set the current time in seconds
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
[time] | number | Time for seek to |
# uzPlayer.getCurrentTime() ⇒ number
Get the current time in seconds
Kind: instance method of UZPlayer
Returns: number
- returns the current time when getting
# uzPlayer.destroy()
Turn off all event, clear the UZPlayer
properties
Kind: instance method of UZPlayer
# uzPlayer.getDuration() ⇒ number
Get the duration in seconds
Kind: instance method of UZPlayer
Returns: number
- Returns the duration
# uzPlayer.setFullscreen(fullscreen)
Set fullscreen to on/off
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
fullscreen | boolean | Set fullscreen - true enter fullscreen - false exit fullscreen |
# uzPlayer.toggleFullscreen()
Toggle fullscreen to on/off
Kind: instance method of UZPlayer
# uzPlayer.getFullscreen() ⇒ boolean
Check if the player is in fullscreen mode
Kind: instance method of UZPlayer
Returns: boolean
- true if fullscreen is on and getting; false if fullscreen is off and getting
# uzPlayer.setMute(muted)
Turn mute on or off
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
muted | boolean | Turn mute on or off: - true to mute - false to unmute |
# uzPlayer.toggleMute()
Toggle muted state to on/off
Kind: instance method of UZPlayer
# uzPlayer.pause()
Pause media playback
Kind: instance method of UZPlayer
# uzPlayer.play()
Start media playback
Kind: instance method of UZPlayer
# uzPlayer.setVolume([percentAsDecimal])
Set the current volume of the media
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
[percentAsDecimal] | number | The new volume as a decimal percent: - 0 is muted/0%/off - 1.0 is 100%/full - 0.5 is half volume or 50% |
# uzPlayer.getVolume() ⇒ number
Get the current volume of the media
Kind: instance method of UZPlayer
Returns: number
- The current volume as a percent when getting
# uzPlayer.setPlayPercentage([percentage])
Set the play percentage of the media
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
[percentage] | number | The new percentage, in range 0~100: - 0 is seek to 0% - 10 is seek to 10% - ... |
# uzPlayer.getPlayPercentage() ⇒ number
Get the play percentage of the media
Kind: instance method of UZPlayer
Returns: number
- The play percentage when getting, in range 0~100
# uzPlayer.getPlaybackState() ⇒ PlaybackState
Get the current playback state of the media
Kind: instance method of UZPlayer
Returns: PlaybackState
- The current current playback state when getting
# uzPlayer.bufferedPercent() ⇒ number
Get the percent (as a decimal) of the video that's been downloaded
Kind: instance method of UZPlayer
Returns: number
- 0 means none, 1 means all.
# uzPlayer.qualities() ⇒ array
Get the video qualites
Kind: instance method of UZPlayer
Returns: array
- - Array of object which have key label
to display
# uzPlayer.getCurrentLevel() ⇒ number
| undefined
Get the level of video quality
Kind: instance method of UZPlayer
Returns: number
| undefined
- returns the current level of video quality when getting
# uzPlayer.setCurrentLevel([level])
Set the level of video quality
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
[level] | number | Level to change |
# uzPlayer.onEnded(callback)
Callback when the end of the media resource is reached.
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
callback | function | The callback function |
# uzPlayer.onError(callback)
Callback when playback error
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
callback | function | The callback function |
# uzPlayer.onFullscreen(callback)
Callback when fullscreen state changed
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
callback | function | The callback function |
# uzPlayer.onLoad(callback)
Callback when the player start to load media
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
callback | function | The callback function |
# uzPlayer.onPause(callback)
Callback when playback changed to PAUSED
Kind: instance method of UZPlayer
See: UZPlayer#PlaybackState
Param | Type | Description |
---|---|---|
callback | function | The callback function |
# uzPlayer.onPlay(callback)
Callback when playback changed to PLAYING
Kind: instance method of UZPlayer
See: UZPlayer#PlaybackState
Param | Type | Description |
---|---|---|
callback | function | The callback function |
# uzPlayer.onPlaybackState(callback)
Callback when playback changed
Kind: instance method of UZPlayer
See: UZPlayer#PlaybackState
Param | Type | Description |
---|---|---|
callback | function | The callback function |
# uzPlayer.onVolume(callback)
Callback when volume changed
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
callback | function | The callback function |
# uzPlayer.onWaiting(callback)
Callback when playback changed to WAITING
Kind: instance method of UZPlayer
See: UZPlayer#PlaybackState
Param | Type | Description |
---|---|---|
callback | function | The callback function |
# uzPlayer.onQualities(callback)
Callback when the list qualities of video change
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
callback | function | The callback function |
# uzPlayer.onLevel(callback)
Callback when the video quality change manualy
Kind: instance method of UZPlayer
Param | Type | Description |
---|---|---|
callback | function | The callback function |
Updating......