Defines the events that the player can emit, and their event data.

interface PlayerEvents {
    durationchange: { duration: number };
    ended: void;
    error: ErrorEventData;
    loadedmetadata: void;
    pause: void;
    play: void;
    ready: { channelId: undefined | string; playerId: string; videoId: string };
    timeupdate: { time: number };
}

Properties

durationchange: { duration: number }

Fired when the duration of the video has changed.

ended: void

Fired when the media has ended.

Fired when an error occurs.

loadedmetadata: void

Triggered when the video metadata has been loaded.

pause: void

Fired when the media has been paused.

play: void

Indicates that playback has started or resumed.

ready: { channelId: undefined | string; playerId: string; videoId: string }

Fired when the player iframe is ready to receive commands. Usually this event doesn't need to be handled, since all player methods wait for the player to be ready before executing.

timeupdate: { time: number }

Fired when the current playback position has changed.