Handle the Player Ready Event
mainThe onReady callback is executed when the player is fully initialized. The callback receives the player instance as its argument, which you can use to call methods or attach event listeners.
Providers like YouTube, Vimeo, and Dailymotion use their internal onready events, while HTML5 uses canplay|loadedmetadata to trigger this.
// Example: Muting the player immediately when ready
new Vlitejs('#player', {
onReady: function (player) {
player.mute();
}
});
// Example: Attaching an event listener when ready
new Vlitejs('#player', {
onReady: (player) => {
player.on('play', () => {
// The video starts playing
});
}
});