Skip to main content

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

MethodArgumentsReturn TypeDescription
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.
setCaptionLanguagelangCode: 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
setVideoQualityid: numberPromise<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
setFullscreenBoolean statusPromise<boolean>Request/exit the full screen for the player
addEventListenereventName: string, handler: (param) => voidcancelSubscription : () => voidListen for the list of available events which are
  • fullscreenChange
  • videoAdaptivenessChange
  • videoQualityChange
  • statusChange
  • captionVisibilityChange
  • captionLanguageChange

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.