API Reference
Welcome to the VP Player API Reference section of this documentation. The VP Player API allows you to enhance the functionality of your video player and create interactive experiences for users. By using the API, you can customize the behavior of your videos and create unique user experiences using the available methods and properties.
Methods
VP Player allows users to use methods for these purposes:
- Control playback methods
- Toggle methods
- State methods
- Get playback properties methods
- Set playback properties methods
Control playback methods
play()
The method vpPlayer().play()
is the method that plays the video
pause()
The method vpPlayer().pause()
is the method that pauses the video
forward()
The method vpPlayer().forward()
is the method that moves the video forward (goes to the next playlist video)
rewind()
The method vpPlayer().rewind()
is the method that moves the video backwards (goes to the previous playlist video)
replay()
The method vpPlayer().replay()
is the method that replays the video from the beginning
seek()
The method vpPlayer().seek()
method allows you to jump to the specified position within the currently playing video. It contains one attribute, which is described below.
ATTRIBUTE | DESCRIPTION |
---|---|
position Number | An attribute that indicates the position (in seconds) to seek to. This is a mandatory attribute. |
mute()
The method vpPlayer().mute()
is the method that mutes the audio on the video
unmute()
The method vpPlayer().unmute()
is the method that un-mutes the audio on the video
enterFullScreen()
The method vpPlayer().enterFullScreen()
is the method that enters full screen mode for the video
exitFullScreen()
The method vpPlayer().exitFullScreen()
is the method that exits full screen mode for the video
destroy()
The method vpPlayer().destroy()
is the method that destroys the video player instance, removing it from the DOM
Toggle methods
togglePlay()
The method vpPlayer().togglePlay()
is the method that toggles the play/pause state of the video based on the current state
toggleMute()
The method vpPlayer().toggleMute()
is the method that toggles the mute/un-mute state of the audio on the video
State methods
isMuted()
The method vpPlayer().isMuted()
is the method that returns a boolean indicating if the audio on the video is currently muted
isPlaying()
The method vpPlayer().isPlaying()
is the method that returns a boolean indicating if the video is currently playing
isPaused()
The method vpPlayer().isPaused()
is the method that returns a boolean indicating if the video is currently paused
isFullscreen()
The method vpPlayer().isFullscreen()
is the method that returns a boolean indicating if the video is currently in full screen mode
Get playback properties methods
getPosition()
The method vpPlayer().getPosition()
is intended to return the viewer's current position in a media file. Values may vary depending on the type of media. See the table below for more information. This method contains two attributes, which are described below.
ATTRIBUTE | DESCRIPTION |
---|---|
VOD Number | This attribute indicates the current playback position for a VOD file, in seconds. |
Live Number | This attribute indicates how long the current stream has been playing, in seconds. |
getBuffered()
The method vpPlayer().getBuffered()
is the method that returns the amount of the video that has been buffered
getVolume()
The method vpPlayer().getVolume()
is the method that returns the current volume of the audio on the video
getContainer()
The method vpPlayer().getContainer()
is the method that returns the container element for the video player
getDuration()
The method vpPlayer().getDuration()
returns the total length of the media file. This varies depending on VOD or live content. This method contains two attributes, which are described below.
ATTRIBUTE | DESCRIPTION |
---|---|
VOD Number | This attribute indicates the length a VOD file, in seconds. |
Live Number | This attribute indicates the maximum seconds the player can seek or Infinity. |
getQualityLevels()
The method vpPlayer().getQualityLevels()
is the method that returns an array of quality levels available for the video
getCurrentQuality()
The method vpPlayer().getCurrentQuality()
is the method that returns the current quality level of the video
checkViewability()
The method vpPlayer().checkViewability()
is the method that checks if the video is viewable within the current viewport
Set playback properties methods
setConfig()
The method vpPlayer().setConfig()
is the method that sets the configuration for the video player
var config = {
// configuration object
};
vpPlayer().setConfig(config);
setVideo()
The method vpPlayer().setVideo()
is the method that sets the video for the video player
var video = {
// configuration of video object from config.video
};
vpPlayer().setVideo(video);
The setVideo() method sets the video object of the player which immediately starts playback. It has one attribute, which is explained below.
ATTRIBUTE | DESCRIPTION |
---|---|
video* JSON | (Required) Video object with data about the video as specified on the full configuration. |
setConfig()
The method vpPlayer().setConfig()
is the method that sets config for the video player
let config = {
// configuration object from config
};
vpPlayer().setConfig(config);
The setConfig() method sets one or more of the following video attributes after the player has already been setup.
ATTRIBUTE | DESCRIPTION |
---|---|
config* JSON | (Required) Config object with player properties as specified in the full configuration. |
setPlaylist()
The method vpPlayer().setPlaylist()
is the method that sets a playlist for the video player
let playlist = {
// configuration of playlist object from config.playlist
};
vpPlayer().setPlaylist(playlist)
There are three ways to initialize a playlist using this method: by a playlist ID, playlist Object, or an external link.
ATTRIBUTE | DESCRIPTION |
---|---|
Playlist ID | If you want to set a playlist which already exists in the VP Player database, you can use its ID as a parameter and initialize it in the player. |
playlist Object | A formatted object that contains in itself an array of video objects, which follows the same format as that of a playlist that is initialized in the setup() method. |
External link | If you want to set a playlist using this method, you can insert your playlist link, which VP Player will parse. |
setVolume()
The method vpPlayer().setVolume()
is the method that sets the volume for the audio on the video from 0 to 1
let volume = 0.5
vpPlayer().setVolume(volume)
ATTRIBUTE | DESCRIPTION |
---|---|
volume Number | An attribute that indicates the volume of the video as a double number from 0 to 1. This is a mandatory attribute. |
setCurrentQuality()
The method vpPlayer().setCurrentQuality()
is the method that sets the current quality level for the video (index 0 is lowest quality, highest index depends on number of video qualities)
let index = 2;
vpPlayer().setCurrentQuality(index);
setLevelToAuto()
The method vpPlayer().setLevelToAuto()
is the method that sets the quality level for the video to "auto” which automatically adjust based on the user's device and connection
setCuePoint()
The method vpPlayer().setCuePoint()
is the method that sets a cue point for the video
let cue = 10;
vpPlayer().setCuePoint(cue, callback)
This method sets a custom function to be called at the specified time on video playback. This method contains two attributes, which are described below.
ATTRIBUTE | DESCRIPTION |
---|---|
cue Number | This attribute indicates the position of the video in seconds which will trigger the function. It is a mandatory attribute. |
callback Function | This attribute indicates the callback that will be called on the set cue. It is a mandatory attribute. |