More API methods
VdoCipher custom api object provides the following methods to access and control on the players.
const iframe = document.querySelector('iframe');
const player = VdoPlayer.getInstance(iframe);
player.api.getTotalPlayed().then((data) => console.log('Total Played: ', data));
player.api
.getTotalCovered()
.then((data) => console.log('Total Video Covered: ', data));
player.api.getMetaData().then((data) => console.log('Video Meta Data: ', data));
List of all the player methods available on VdoCipher custom api
Method | Arguments | Return Type | Description |
---|---|---|---|
getTotalPlayed | - | Promise<number> | Total number of seconds video watched by the user. It includes the count of repetitive seen of video part. |
getTotalCovered | - | Promise<number> | Total number of seconds video has been covered. |
getTotalCoveredArray | - | Promise<number[]> | Total covered Array Object. |
getCaptionLanguages | - | Promise<{visible: boolean; languages: Caption[]}> | Get the caption visibility status along with the list of available captions with id , useful for the setCaptionLanguage method if one more captions share same lang code. |
setCaptionLanguage | langCode: string -or {id: number} | Promise<void> | Set the captions language. you can pass the langCode (Eg: 'in', 'gb', 'de') to method to set caption language, but if one more captions share same langCode then pass the object with id of track. list of all the captions with id can be retrieve by player.api.getAvailableCaptions() |
hideCaptions | - | Promise<void> | hides the captions |
getVideoQualities | - | Promise<{adaptive: boolean; qualities: Quality[]}> | Get the video quality adaptiveness status along with list of available quality with id , useful for manual bitrate switching via setVideoQuality method |
setVideoQuality | id: number | Promise<void> | choose the quality (bitrate) by id , all the available video quality can be fetched via getVideoQualities method. |
enableAdaptiveVideo | - | Promise<void> | Enable auto-adaptive switching of bitrates for video |
setFullscreen | Boolean status | Promise<boolean> | Request/exit the full screen for the player |
addEventListener | eventName: string, handler: (param) => void | cancelSubscription : () => void | Listen for the list of available events which are
for event related to HTML5 video DOM events use player.video.addEventListener |
loadVideo | {otp: string; playbackInfo: string} | Promise<void> | Load another video within an existing video player. Can be used to build playlists. Check this sample code of loadVideo to learn usage. |