- getAudioStreams() ⇒ Array<AudioStream>
- getCurrentAudioTrack() ⇒ AudioTrack
- getCurrentSubtitle() ⇒ number
- getCurrentTime() ⇒ number
- getCurrentTrack() ⇒ Track
- getDuration() ⇒ number
- getQualityLevels() ⇒ Array
- getSubtitles() ⇒ Array
- getThumbnailAt() ⇒ Promise
- getThumbnails() ⇒ Array<Frame>
- getTracks() ⇒ Array<Track>
- getURL() ⇒ string
- getVersion() ⇒ string
- getPlayerDiv() ⇒ string
- getPlayerContainerDiv() ⇒ string
- getAdInstance() ⇒ string
- getVolume() ⇒ number
- getMute() ⇒ boolean
- getLogger() ⇒ Logger
- isCurrentAssetAd() ⇒ boolean
- isCurrentAssetMuted() ⇒ boolean
- isSeeking() ⇒ boolean
- setAudio(streamID)
- setCurrentTrack(trackID)
- setCurrentSubtitle(subID)
- setVolume(number)
- setMute(boolean)
- setLogger(logger)
- NexPlayerDRMOptions : object
- DRMCustomData : object
- Captions : object
- Thumbnails : object
- ICaptionsDisplayer : object
- getAdType() ⇒ string
- getAdTitle() ⇒ string
- getAdDuration() ⇒ number
- getAdRemainingTime() ⇒ number
- getMute() ⇒ boolean
- getVolume() ⇒ number
- getAdBreaks() ⇒ Object
Creates and initializes the player.
Type: instance method of nexplayer
Parameters: configObj is an object which values could be:
| Param | Type | Description |
|---|---|---|
| key | string |
NexPlayer key to validate the playback. |
| div | HTMLDivElement |
The div container of the player. |
| src | string |
URL of the video to be played. |
| drm | NexPlayerDRMOptions |
Contains an object of DRM information. By default it's set to null. |
| adURL | string |
Contains an object of DRM information. By default it's set to null. |
| adsParamsToEncode | Array |
Array of strings specifying the parameters in the ad URL to be encoded. |
| autoplay | boolean |
Determines if the video must start playing or paused. True by default. |
| callbacksForPlayer | Function |
Used for retrieving the NexPlayer instance and video element. This is necessary for getting the instance and use the NexPlayer API. |
| captionDisplayer | ICaptionsDisplayer |
Used to provide a custom CaptionDisplayer. Tihs allows to implement the internal logic for the captions. |
| debug | boolean |
Determines if log information is showed. By default is set to true. |
| externalSubtitles | Captions |
Used to provide a WEBVTT file as external subtitles. |
| mutedAtStart | boolean |
Determines if the video will start playing muted or not. False by default. |
| resumePosition | number |
Determines the position where the video will start playing. |
| thumbnails | Thumbnails |
Thumbnails to be shown. Static and dynamic thumbnails are supported. |
| trailer | boolean |
Determines if a stream should be considered a trailer. |
| useNewRelicTracker | boolean |
Determines if the New Relick tracker will be used. |
| vast | string |
Advertisement url that is going to be played. VAST, VPAID, VMAP are supported. |
Unmounts the player and its dependencies.
Type: instance method of nexplayer
Parameters:
| Param | Type | Description |
|---|---|---|
| div | HTMLElement |
Player tag |
Listens for player events.
Type: instance method of nexplayer
Parameters:
| Param | Type | Description |
|---|---|---|
| event | string |
Event name |
| callback | function |
Callback function |
Listens for ads events.
Type: instance method of nexplayer
Parameters:
| Param | Type | Description |
|---|---|---|
| event | string |
Event name |
| callback | function |
Callback function |
Initialize the player with the config object given.
Type: instance method of Player
Plays the video when it is paused.
Type: instance method of Player
Pauses the video when it is playing.
Type: instance method of Player
Seek the video to the value given.
Type: instance method of Player
Return a boolean, true if the player is seeking and false if not.
Type: instance method of Player
Returns which browser, platform and device type are set.
Type: instance method of Player
Sends the default configuration in case the parameters are not specified in the init.
Type: instance method of Player
Destroy the player
Type: instance method of Player
Gets the available audio streams.
Type: instance method of Player
Returns: An Array - which contains the available audio streams.
Gets the audio track currently in use.
Type: instance method of Player
Returns: AudioTrack - The current audio track.
Gets the current subtitle info.
Type: instance method of Player
Returns: Current Subtitle - the current subtitle track (undefined if no subtitles are activated).
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.
Gets the current track information.
Type: instance method of Player
Returns: Track - the current track.
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.getQualityLevels() ⇒ Array
Gets the video quality levels array.
Type: instance method of Player
Returns: Array - quality levels array info
Gets all the avaliable subtitle tracks info.
Type: instance method of Player
Returns: Array of subtitles - the subtitle tracks of the video.
Returns a thumbnail loading promise in a specific time.
Type: instance method of Player
Returns: Promise - Thumbnail loading promise in a specific time.
Returns the loaded thumbnails.
Type: instance method of Player
Returns: Array < Frame > - The loaded thumbnails.
Gets all of the videos avaliable tracks (different qualities).
Type: instance method of Player
Returns:: Array.< Track > - all the tracks available.
Returns the current video URL.
Type: instance method of Player
Returns: String
Returns the current version of the player.
Type: instance method of Player
Returns: String
Returns the video container.
Type: instance method of Player
Returns: HTMLDivElement
Returns the player container.
Type: instance method of Player
Returns: HTMLDivElement
Returns the AdInstance Object.
Type: instance method of Player
Returns: Object
Returns the current volume of the Player.
Type: instance method of Player
Returns: number
Returns true if the video is muted and false if not.
Type: instance method of Player
Returns: boolean
Returns the logger of the Player.
Type: instance method of Player
Returns: Object
Returns a boolean, true if the current playing asset is an ad, false if not.
Type: instance method of Player
Returns a boolean, true if the current playing asset is muted, false if not.
Type: instance method of Player
Returns a boolean, true if the player is seeking and false if not.
Type: instance method of Player
Sets the current audio stream.
Type: instance method of Player
| Param | Type | Description |
|---|---|---|
| streamID | number |
ID of the audio stream to be used. |
Sets the current track.
Type: instance method of Player
| Param | Type | Description |
|---|---|---|
| trackID | number |
ID of the track to be used. |
Sets the current subtitle.
Type: instance method of Player
| Param | Type | Description |
|---|---|---|
| subID | number |
ID of the subtitle to be used. |
Set the volume of the video.
| Param | Type | Description |
|---|---|---|
| value | number |
The volume level to be used. |
Set mute or unmute to the video.
| Param | Type | Description |
|---|---|---|
| boolean | boolean |
If the video will be mute or unmute. |
Set logger to the video.
| Param | Type | Description |
|---|---|---|
| logger | Object |
The logger to be used. |
Type: global typedef Properties:
| Name | Type | Description |
|---|---|---|
| keySystem | string |
DRM's keySystem type. I.E.: "com.widevine.alpha" |
| license | string |
DRM's license. |
| customData | DRMCustomData |
Used to indicate the custom headers necessary to request the license. Optional. |
Type: global typedef Properties:
| Name | Type | Description |
|---|---|---|
| fieldName | string |
Header's name . |
| value | string |
Value used in the DRM's request. |
Type: global typedef Properties:
| Name | Type | Description |
|---|---|---|
| src | string |
Caption's URL. |
| language | string |
Language of the captions. Use to identificate them. |
Type: global typedef Properties:
| Name | Type | Description |
|---|---|---|
| canvas | HTMLCanvasElement |
Canvas used to display the thumbnails. |
| urlVtt | string |
VTT's URL. |
| urlImg | string |
Image to extract thumbnails from. |
| chunkLimit | number |
Number of thumbnails' chunks available at the same time. |
| chunkTotal | number |
Number of thumbanils' chunks in total. |
Type: global typedef Properties:
| Name | Type | Description |
|---|---|---|
| _videoContainer | HTMLElement |
Canvas used to display the thumbnails. |
| _captionsContainer | HTMLElement |
VTT's URL. |
Functions:
| Name | Params | Returns | Description |
|---|---|---|---|
| init | cues: Array |
void | Initializes the Caption Displayer. |
| destroy | None | void | Destroy the Caption Displayer. |
| reset | None | void | Resets the Caption Displayer. |
| setTextVisibility | visible: boolean |
void | Shows/hides the captions. |
| updateCue | time: number |
void | Called to update the current cues to display. |
| displayCuesCC | cuesCC:Map<string, Object> |
void | Displays the CC cues passed. Object properties: "text", "position", and "rgba". |
Plays the ad when it is paused.
Type: instance method of nexplayer
Pauses the ad when it is playing.
Type: instance method of nexplayer
ads is an Object that implements IAds interface, The users can pass their own implementation in case they want to use another advertisement library or a custom one.
Type: instance method of nexplayer
Return a boolean, true if the ad is playing and false if not.
Type: instance method of nexplayer
Skip the current ad if possible.
Type: instance method of nexplayer
Checks whether there ads
Type: instance method of nexplayer
Gets the current Ad type.
Type: instance method of nexplayer
Returns: String - The current ad type.
Gets the Ad title.
Type: instance method of nexplayer
Returns: String - The current ad title.
Gets the Ad duration.
Type: instance method of nexplayer
Returns: number - The current ad duration.
Gets the Ad remaining time.
Type: instance method of nexplayer
Returns: number - The ad remaining time.
Gets the true if the video is muted or false if not.
Type: instance method of nexplayer
Returns: boolean - True if the video is muted or false if not.
Gets the Ad volume.
Type: instance method of nexplayer
Returns: number - The ad volume.
Returns the break points when ads will trigger
Type: instance method of nexplayer
Returns: Object - The break points when ads will trigger
Mutes or unmutes the ad.
| Param | Type | Description |
|---|---|---|
| state | boolean |
If the ad will be mute or unmute. |
Set the volume of the ad.
| Param | Type | Description |
|---|---|---|
| value | number |
The volume level to be used. |
We have events to handle some different kind of player events. List of player events available:
- statechanged: Event is fired when the state of player is changed, contains in the detail attribute the different states of the player (Ready, Buffering, Playing, Paused, Ended)
- playercreating: Event lauched when the player is being created.
- playercreated: Event launched when the player has been created.
- playerdestroyed: Event launched when the player has been destroyed.
- play: Event launched when play is requested.
- playing: Event launched when the player is played.
- pause: Event launched when pause is requested.
- paused: Event launched when the player is paused.
- seeking: Returns a boolean. True when is seeking, false otherwise.
- seeked: Event launched when the stream has been seeked.
- stalled: Event launched when the stream has been stalled.
- hovering: Event launched when the cursor hovers over the seekbar.
- durationchange: Event launched when video duration is changed.
- timeupdate: Event launched when the video element duration changes.
- loadstart: Event launched when the player starts loading.
- loadeddata: Event launched when the manifest is loaded.
- canplay: Event launched when the player is ready to play.
- buffering: Event launched when the player is buffering.
- bufferType: Event launched indicating what type of buffering happened: "Connection", "Initial", "Seek" or "Background".
- videofirstquartile: Event is fired when the 25% of the video’s duration has been reached.
- videomidpoint: Event is fired when the 50% of the video’s duration has been reached.
- videothirdquartile: Event is fired when the 75% of the video’s duration has been reached.
- ended: Event launched when the stream has been finished.
- subtitlesdataloaded: Event launched when captions are loaded.
- newsubtitlesdataloaded: Event launched when new captions are loaded.
- ccnewdata: Event launched when new captions are received.
- thumbnaildata: Event launched when a thumbnail data is received.
- thumbnailloaded: Event launched when a thumbnail is loaded to the thumbnail array.
- thumbnailreply: Event launched when a thumbnail is provided to the canvas.
Example on how to listen for a player event:
nexplayer.PlayerEvents("playing", function(e) {
console.log("playing", e);
});We have events to handle some different kind of ads events. List of ad events available:
- adlibrarycreating: Creates a library with all ads when the player is started.
- adlibrarycreated: Event launched when the ads library is created.
- adlibrarydestroyed: Destroys the library with all ads when the player is started.
- adpodsinfo: Contains all ad pods information.
- adblockstarted: Contains the number of ads in the block in the detail attribute.
- adblockend: Event launched when an ad block (some ads in the same timestamp) ends.
- adstarted: Event launched when when the ad has started, contain the ad position in the block in the detail attribute.
- adtagstartloading: Event launched when the ad starts.
- adloaded: Event launched when the ad has been loaded.
- adcomplete: Event launched when the ad has ended.
- addestroyed: Event launched when the ad has been destroyed after ended.
- adpaused: Event launched when an ad is paused.
- adresumed: Event launched when an ad is resumed.
- adskipped: Event launched when an ad is skipped.
- adfirstquartile: Event is fired when the 25% of the ad’s duration has been reached.
- admidpoint: Event is fired when the 50% of the ad’s duration has been reached.
- adthirdquartile: Event is fired when the 75% of the ad’s duration has been reached.
- adimpression: Event launched when ad impression is sent to the server.
- aderror: Event launched when there is an error loading the ad.
- adpodcompleted: Event launched when an ad block has been completed.
nexplayer.AdsEvents("aderror", function(e) {
console.log("aderror", e);
});