Skip to content

Latest commit

 

History

History
1015 lines (640 loc) · 31.8 KB

File metadata and controls

1015 lines (640 loc) · 31.8 KB

NexPlayer API

Player

Type: global class

nexplayer.Setup(info)

Creates and initializes the player.

Type: instance method of Player
Param: info is and object which its values could be:

Param Type Description
key string that validates the playback.
div HTMLDivElement the div container of the player.
src string of the video to be played.
autoplay boolean determine if the video must start playing or paused. By default it's set to true.
drm Array. contains an array of DRM information. By default it's set to null.
seekUI number establish the number of seconds the UI buttons will seek forwards or backwards. By default is set to 10s.
mutedAtStart boolean determine if the video will start playing muted or not. By default this value is set to false.
debug boolean determine if log information is showed. By default is set to true.
type_360 string select the 360 video format to play. Possible values are 'equirectangular', 'cubemap' and 'topdown'.
autohide boolean establish if the UI must hide when the user does not interact with the video. By default is set to true..
callbacksForPlayer function used for retrieving the nexplayer instance and video element. This is necessary for getting the instance and use the NexPlayer API.
callbackForReturn function establish a callback to be executed when the corresponding button is clicked.
callbackForLogger function function to be called when the logger show a message.
vast string advertisement url that is going to be played. VAST, VPAID, VMAP are supported.
useDynamicThumbnails boolean determine if dynamic thumbnails are used. By default this values is set to false.
showingFullUI boolean determine if the UI is hidden or not.
disableKeyEvents boolean determine if the keyboard keys can be used to control the video (play/pause, forward/backward and volume up/down).

player.getTracks() ⇒ Array.< Track >

Get all the video avaliable tracks (different qualities).

Type: instance method of Player
Returns:: Array.< Track > - all the tracks available.

player.getCurrentTrack() ⇒ Track

Get the current track information.

Type: instance method of Player
Returns: Track - the current track.

player.setCurrentTrack(trackID)

Set the current track.

Type: instance method of Player
Export:

Param Type Description
trackID number ID of the track to be used.

player.enableABR()

Enable the ABR to change automatically between tracks.

Type: instance method of Player

player.getAudioStreams() ⇒ Array.< AudioStream >

Get the available audio streams.

Type: instance method of Player
Returns: Array. - the list of the available audio streams.

player.getCurrentAudioStream() ⇒ AudioStream

Get the audio stream currently in use.

Type: instance method of Player
Returns: AudioStream - the current audio track.

player.setAudioStream(streamID)

Set the current audio stream.

Type: instance method of Player
Export:

Param Type Description
streamID number ID of the audio stream to be used.

player.getCurrentSubtitle()

Get the current subtitle info.

Type: instance method of Player
Returns: Current Subtitle - the current subtitle track (undefined if no subs are activated).

player.getSubtitles()

Get all the avaliable subtitle tracks info.

Type: instance method of Player
Returns: Array of subtitles - the subtitle tracks of the video.

player.setSubtitle(subID)

Set the current subtitle track.

Type: instance method of Player
Export:

Param Type Description
subID number ID of the subtitle track to be used

player.isLive() ⇒ boolean

Informs whether the video is live or on demand (VOD). Needs to be called when the manifest is finally loaded. It is recommended to use within the video "loadeddata" event.

Type: instance method of Player
Returns: boolean - true if the video is live, false otherwise.

player.on(callbackType, functionToBeCalled)

Adds a listener for Events.

Type: instance method of Player
Export:

Param Type Description
callbackType NexEvent Event to listen for
functionToBeCalled NexCallbackEvent Function called on each event

player.attachSubtitleRendererDiv(subtitleRendererDiv)

Adds a DIV to render certain subtitles in a more precise way. This is optional and the native subtitles of the video element will be used if this is not set.

Type: instance method of Player
Export:

Param Type Description
subtilteRendererDiv SubtitleRendererDiv DIV to render some advanced subtitles

player.create360View()

Creates the 360 view.

Type: instance method of Player

player.FairPlayNexLicenseRequestLoaded(event)

Called when the FairPlay request is done.

Type: instance method of Player
Export:

Param Description
event Event

player.FairPlayNexLicenseRequestFailed(event)

Called if the FairPlay request fails.

Type: instance method of Player
Export:

Param Description
event Event

player.setThumbnailResources(callback, vttURl, imageURL)

Sets thumbnail resources. This method should be called before Init().

Type: instance method of Player
Export:

Param Type Description
callback NexCallbackEvent function called when the thumbnails are loaded
vttURl String path to the .vtt thumbnails file
imageURL String path to the thumbnails image file

player.isUTC() ⇒ boolean

Indicates whether the video information (currentTime, duration, seekable range, etc.) of the video element is based on the present or on an absolute value that starts at midnight UTC, Jan 1, 1970. If this is true, you will need to take this into account when seeking through the currentTime of the video element. Some useful methods (like getCurrentTime, getDuration, and seek) are available to reduce the complexity in these cases. Note that this property only applies to live streams.

Type: instance method of Player
Returns: boolean - true if the video information is using UTC, false otherwise.

player.getCurrentTime() ⇒ number

Returns the currentTime taking into account isUTC (if isUTC is true, getCurrentTime's returned value will be different from the time of the video element).

Type: instance method of Player
Returns: number - the current time of the video.

player.getDuration() ⇒ number

Returns the duration taking into account isUTC (if isUTC is true, getDuration's returned value will be different from the duration of the video element).

Type: instance method of Player
Returns: number - the duration of the video.

player.getDVRWindowSize() ⇒ number

Returns the window of allowable play time behind the live point of a live stream, this value will increase until the buffer is full, with the full content, at that point of time, the value will be constant.

Type: instance method of Player
Returns: number - the window of allowable play time behind the live point of a live stream.

player.getURL()

Returns the current video URL.

Type: instance method of Player
Returns: String

player.checkFrameDrop() ⇒ number

Returns the number of dropped frames as proxy for CPU load

Type: instance method of Player
Returns: number - number of dropped frames.

player.seek(value)

Set the currentTime property of the attached video element. (if isUTC is true, the seek value will be in a different format than the currentTime of the video element).

Type: instance method of Player

Param Type Description
event Event value in seconds that the player will seek to.
 //Non-live video 
 player.seek(120) // It seeks into minute 2:00 in the video (120 secs), must be a positive number ranging from 0 to the full duration of the video in seconds
 //Live video
 player.seek(-120) // It jumps back 2 minutes (120 secs) from the current live time, must be a negative number ranging from minus {the DVR window size} to 0

player.seekLive()

Jump to the livestream current time from the current position (if isUTC is true, the seek value will be in a different format than the currentTime of the video element). only works in livestream.

Type: instance method of Player

player.getCurrentLiveTime() ⇒ number

Returns the time in which the livestream is at.

Type: instance method of Player
Returns: number - time in which the livestream is at.

player.getTimeUntilLive() ⇒ number

Returns the time difference between the time it's currently found in and the time the livestream is at.

Type: instance method of Player
Returns: number - time difference between the time it's currently found in and the time the livestream is at.

player.getManifestInfo()

Returns some information about the manifest.

Type: instance method of Player
Returns: number - some information about the manifest.

player.getTimeShiftBufferDepth ⇒ number

Returns the time shift buffer depth in seconds, this function only works in livestream.

Type: instance method of Player
Returns: number - time shift buffer depth

#### player.sendImpression()

Send the impression details to the server (only for internal management).

Type: instance method of Player

player.getProtocol() ⇒ number

Returns the protocol type.

Type: instance method of Player
Returns: number - the protocol type.

player.getThumbnailController() ⇒ ThumbController

Returns the preview thumbnail controller.

Type: instance method of Player
Returns: ThumbController - Thumbnail controller

player.setThumbnailStep(step)

Set the time interval between frames for dynamic thumbnails.

Type: instance method of Player

Param Type Description
step number the seconds between two different thumbnails.

player.enablePreviewThumbnails(option)

Enable thumbnails preview. This method must be called before Init().

Type: instance method of Player

Param Type Description
option boolean the value that enable or not the thumbnails.

player.setSpeed(speed)

Set the video playback speed.

Type: instance method of Player

Param Type Description
speed number the speed value.


#### player.getQualityLevels() ⇒ array

Get the video quality levels array.

Type: instance method of Player
Returns: array - quality levels array info

player.setTrack(qualityLevel)

Set the video quality level.

Type: instance method of Player

player.togglePlayPause()

Toggle between play and pause.

Type: instance method of Player

player.toggleFullScreen()

Toggle between full screen and windowed.

Type: instance method of Player

player.showStats()

Display basic stream information when typing "nex" on the keyboard.

Type: instance method of Player

player.jumpForward(value)

Jumps forward to the current playback position of the player.

Type: instance method of Player
Param: {number} value is the number of seconds to jump forward

player.jumpBackward(value)

Jumps backward to the current playback position of the player.

Type: instance method of Player
Param: {number} value is the number of seconds to jump backward

player.setThumbnailStep(step)

Set the step for dynamic thumbnails.

Type: instance method of Player
Param: {number} step is the seconds between two different thumbnails

player.getCurrentLiveLatency()

Returns the live latency value.

Type: instance method of Player
Returns: latency number of seconds

player.getCurrentBuffer()

Returns the current buffer level.

Type: instance method of Player

player.isControlBarOpen()

Returns if the control bar is opened.

Type: instance method of Player
Returns: boolean

player.toggleLanguagesMenu()

Toogle the subtitles menu options.

Type: instance method of Player

player.nextFocus()

Moves along to the next element that can be focused. The possible elements to be focused are: 'nexplayer_play_pause', 'nexplayer_full_volume_div', 'nexplayer_language', 'nexplayer_full_screen', 'nexplayer_return_container'

Type: instance method of Player

player.previousFocus()

Moves along to the previous element that can be focused. The possible elements to be focused are: 'nexplayer_play_pause', 'nexplayer_full_volume_div', 'nexplayer_language', 'nexplayer_full_screen', 'nexplayer_return_container'.

Type: instance method of Player

player.clickFocus()

Click the current focused element.

Type: instance method of Player

player.adManager()

Returns the AdManager instance in order to perform actions on ads through the IMA SDK.

Type: instance method of Player
Returns: AdManager object

player.adManager().getAdObject()

Returns the IMA SDK manager object.

Type: instance method of Player
Returns: IMAs AdManager object

player.adManager().getId()

Returns the ID of the current ad.

Type: instance method of Player
Returns: String

player.adManager().getTitle()

Returns the title of the current ad.

Type: instance method of Player
Returns: String

player.adManager().getDescription()

Returns the description of the current ad.

Type: instance method of Player
Returns: String

player.adManager().getMediaURL()

Returns the video ad URL.

Type: instance method of Player
Returns: String

player.adManager().getSurveyURL()

Returns the ad survey URL.

Type: instance method of Player
Returns: String

player.adManager().getDuration()

Returns the total duration of the current ad.

Type: instance method of Player
Returns: number

player.adManager().getSkipTime()

Returns how much time is left until the user can skip the ad (only if it is skippable).

Type: instance method of Player
Returns: number

player.adManager().getCurrentTime()

Returns the current time position of the ad.

Type: instance method of Player
Returns: number

player.adManager().getContentType()

Returns the ad video type (e.g. "video/mp4").

Type: instance method of Player
Returns: String

player.adManager().isSkippable()

Returns whether the ad is skippable or not.

Type: instance method of Player
Returns: boolean

player.adManager().isLinear()

Returns whether the ad is linear or not.

Type: instance method of Player
Returns: boolean

player.adManager().isVpaid()

Returns whether the ad is in the VPAID format or not.

Type: instance method of Player
Returns: boolean

player.adManager().pause()

Pauses the ad.

Type: instance method of Player

player.adManager().play()

Plays the ad when it is paused.

Type: instance method of Player

player.adManager().skip()

Skips the ad (if possible).

Type: instance method of Player

player.adManager().abort()

Closes the ad and starts the video.

Type: instance method of Player

player.adManager().addClickListener(func)

Sets a listener function called each time the user clicks on the ad.

Type: instance method of Player

Param Type Description
func function the function called when the user clicks on the ad

player.adManager().addVolumeMutedListener(func)

Sets a listener function called each time the user mutes the ad's volume.

Type: instance method of Player

Param Type Description
func function the function called when the user mutes the ad

player.adManager().addVolumeChangedListener(func)

Sets a listener function called each time the user changes the ad's volume.

Type: instance method of Player

Param Type Description
func function the function called when the user changes the ad's volume

player.adManager().addSkippedListener(func)

Sets a listener function called each time the user skips the ad.

Type: instance method of Player

Param Type Description
func function the function called when the user skips the ad

player.adManager().addPausedListener(func)

Sets a listener function called each time the user pauses the ad.

Type: instance method of Player

Param Type Description
func function the function called when the user pauses the ad

player.adManager().addResumedListener(func)

Sets a listener function called each time the user resumes the ad.

Type: instance method of Player

Param Type Description
func function the function called when the user resumes the ad

player.adManager().addStartedListener(func)

Sets a listener function called when the ad starts.

Type: instance method of Player

Param Type Description
func function the function called when the ad starts

player.adManager().addFirstQuartileListener(func)

Sets a listener function called when the ad reaches the first quartile of the video duration.

Type: instance method of Player

Param Type Description
func function the function called when the ad reaches the first quartile of the video duration

player.adManager().addMidpointListener(func)

Sets a listener function called when the ad reaches the middle of the video duration.

Type: instance method of Player

Param Type Description
func function the function called when the ad reaches the middle of the video duration

player.adManager().addThirdQuartileListener(func)

Sets a listener function called when the ad reaches the third quartile of the video duration.

Type: instance method of Player

Param Type Description
func function the function called when the ad reaches the third quartile of the video duration

player.adManager().addCompleteListener(func)

Sets a listener function called when the ad finishes.

Type: instance method of Player

Param Type Description
func function the function called when the ad finishes

player.adManager().addImpressionListener(func)

Sets a listener function called when the impression URL has been pinged.

Type: instance method of Player

Param Type Description
func function the function called when the impression URL has been pinged

player.adManager().addErrorListener(func)

Sets a listener function called when the ad fails during loading or playing.

Type: instance method of Player

Param Type Description
func function the function called when the ad fails during loading or playing

player.adManager().addBlockedListener(func)

Sets a listener function called when the ad is blocked by an external app.

Type: instance method of Player

Param Type Description
func function the function called when the ad is blocked by an external app

Player.NexProtocol : enum

Type: static enum of Player
Read only: true
Properties:

Name Type Default
HLS number 0
DASH number 1
PROGRESSIVE_DOWNLOAD number 2
UNKNOWN number 3
OTHER number 4

Player.NexEvent : enum

Type: static enum of Player
Read only: true
Properties:

Name Type Default
Track_Change number 0
Fragment_Loading_Completed number 1

Player.THUMB_TYPE : enum

Type: static enum of Player
Read only: true
Properties:

Name Type Default
STATIC_THUMBNAILS number 0
DYNAMIC_THUMBNAILS number 1

NexCallbackEvent : function

Called when a NexEvent happens.

Type: global typedef

NexCallback : function

Called when a FairPlay content needs to request the license.

Type: global typedef

Param Description
event when the webkitkeymessage event from FairPlay is called.

NexHeaders : Object

Type: global typedef
Properties:

Name Type Description
FieldName string of the HTTPHeaders.
FiledValue string of the HTTPHeaders.

NexDRMInformation : Object

Type: global typedef
Properties:

Name Type Description
NexDRMType string NexDRMType of the video.
NexDRMKey string NexDRMKey of the video.
NexHeaders Array.<NexHeaders> NexHeaders of the video.
NexCallback NexCallback NexCallback for FairPlay content.

Track : Object

Type: global typedef
Properties:

Name Type Description
width number width of the video.
height number height of the video.
bitrate number bitrate of the video.
id number id of the video.

AudioStream : Object

Type: global typedef
Properties:

Name Type Description
id number id of the stream.
language number language of the stream.
name number name of the stream.