Player API
Anytime a script based embed is used, VideoKen exposes a standard Javascript API that can be used to programmatically control the Player.
First, if you don’t have a reference to the Videoken player object, you need to get one
const player = VideoKenPlayer();
The following methods/properties are exposed on the player object
Method | Parameters | Description | Return Type |
---|---|---|---|
play() | - | Play the video | - |
pause() | - | Pause the video | - |
seek(position) | Integer | Seek the video to position (seconds). The playstate will not change | - |
seekPlay(position) | Integer | Seek the video to position (seconds) and start playing | - |
getCurrentTime() | - | Returns the current time video is at | Float |
reset() | - | Closes all VideoKen controls | - |
isReady() | - | Returns whether the VideoKen API is ready | Boolean |
getDuration | - | Returns the duration of the video | Float |
The player exposes also a set of events. To listen to the events, use the following syntax
player.on('eventname', function(object) {
// Custom code
})
The following events are exposed on the player object
Event | Event object | Description |
---|---|---|
ready | null | This event is fired when the underlying Player and the VideoKen API is ready |
play | null | This event is fired whenever the video starts playing |
pause | null | This event is fired whenever the video is paused |
end | null | This event is fired when the video has reached the end, or the time specified by the ‘et’ parameter is crossed |
seek | Integer (The time to which video is seeked) | This event is fired whenever the video is seeked |
timeUpdate | Integer (Current time) | If the video is playing, this event is fired every second with the current time |
buffer | - | This event is fired when the player enters a buffering state |
controlsVisible | - | This event is fired when VideoKen controls appear |
controlsHidden | - | This event is fired when VideoKen controls disappear |
Note: Some of the above events might be missing on some players.