Skip to main content

Events Reference

Event Usage

Certain events are triggered when the player does something. Certain events also return information. You will find the plethora of events listed and divided based on their function down below.

Currently, VP Player events support the following event triggers:

LISTENERDESCRIPTIONEXAMPLE
on(event)Using an on listener will continually listen for an event for a specified player. If this player is removed and set up again, the listener will also need to be reinstated.vpPlayer().on(event, [callback])
once(event)Listens for an event a single time. The listener removes itself once it has fired.vpPlayer().once(event, [callback])
off(event)Removes a listener that was added with on(). Pass the same callback reference you passed to on().vpPlayer().off(event, callback)
offAll(event)Removes every listener registered for an event on this player.vpPlayer().offAll(event)

You can see an example of this code being used below. The below event triggers every time a volume change is initiated and will return a number called "volume" within an object.

vpPlayer().on("play", (e) => {
vpPlayer().setVolume(0.7);
});

The tables of events below are divided into Playback Events, Player State Events, Timed Link Events, Playback Health Events, Ad Events, and Analytics Events.

Playback Events

EVENTDESCRIPTION
beforeCompleteFired just before the player completes playing. Unlike the onComplete event, the player will not have moved on to either showing the replay screen or advancing to the next playlistItem.
bufferChangeFired when the currently playing item loads additional data into its buffer.
bufferFullFired when buffer is full.
castTriggered when a cast property changes.
completeFired when an item completes playback.
errorSignals a critical error in the playback process.
firstFrameTriggered by a video's first frame event (or the instant an audio file begins playback). This event pinpoints when content playback begins.
levelsChangedFired when the active quality level is changed.
muteTriggered when the player has gone in or out of a mute state.
pauseFired when the player enters the paused state.
playFired when the player enters the playing state.
playlistItemFired when the playlist index changes to a new playlist item. This event occurs before the player begins playing the new playlist item.
readySignifies when the player has been initialized and is ready for playback. This is the earliest point at which any API calls should be made.
seekFired immediately when a seek action starts.
seekedFired immediately when a seek action ends.
subtitleChangeSent when the user changes the subtitle for this video.
timeWhile the player is playing, this event is fired as the playback position gets updated. This may occur every 5 seconds.
visualQualityFired when the active quality level is changed for HLS. This is different from levelsChanged since this will trigger when adaptive streaming automatically shifts quality.

Player State Events

EVENTDESCRIPTION
floatTriggered when the player has gone in or out of a float state.
fullscreenFired when the player toggles to/from fullscreen.
nextClickFired when user click on next video.
relatedOpenTriggers when the recommendations videos list is opened.
sharingOpenListens for the opening of the share interface.
viewableFired when the viewable property of the player changes.
interruptedFired once when a livestream is disrupted by a sustained buffer stall or a network or media error. The event detail includes reason (bufferStall, networkError, mediaError or otherError), multiStream, and currentTime. Livestreams only.
recoveredFired once after a livestream recovers from an interruption. The event detail includes currentTime.
EVENTDESCRIPTION
timedLinkShowFired when a timed link becomes visible or switches to another link. The event detail carries the link: title, url, time, and duration when one is set.
timedLinkClickFired when the viewer clicks a timed link. The event detail carries the same fields as timedLinkShow.

Playback Health Events

These events report whether playback worked, so integrations can monitor stream health from the page. Only unexpected failures are reported here — geo-blocked videos, videos that are not published yet, password prompts and paywall locks are intentional outcomes and are not counted as failures.

EVENTDESCRIPTION
playAttemptFired once per view when playback is first requested, either by autoplay or by the viewer. The event detail adds autoStart (true when the player started playback on its own) to the shared payload below.
fatalErrorFired at most once per view, when the player gives up on the video and shows the error screen. A fatal error always implies an attempt, so the player backfills playAttempt if it was never fired.
errorRecoveredFired every time an error that would have been fatal was survived by a fallback and playback resumed. The event detail adds recoveryReason and recoveryMethod.
autoplayBlockedFired when the browser blocks autoplay, after both the unmuted and the muted attempt were rejected. The event detail includes autoStart. This is a browser policy, not a playback failure, so no fatal error is reported.

A view is one watch of one video: moving to the next video in a playlist, setting a new video through the API, and replaying a finished video each start a new view. All events from the same view share the same uniqueViewId, which is the property to join them on. Ads belong to the view of the video they play in and never produce an attempt of their own.

playAttempt, fatalError and errorRecovered share the following payload:

PROPERTYDESCRIPTION
eventattempt, fatal-error or error-recovered.
uniqueViewIdThe identifier shared by all events of the current view.
userIdThe viewer identifier used by analytics.
videoIdThe ID of the current video.
playerIdThe configuration ID of the player.
projectIdThe project the player belongs to.
fileThe source URL of the current video, with the query string removed.
isLiveWhether the current video is a live stream.
currentTimeThe playback position when the event was fired.
playerSdkVersionThe version of the player that produced the event, so attempt and error rows can be grouped by player version.

fatalError adds the following properties:

PROPERTYDESCRIPTION
categoryThe broad class of the failure: network, media, drm, unsupported or other.
fatalReasonThe specific reason, see the table below.
locationA numeric code matching fatalReason, useful for grouping in dashboards.
phasestart when playback had not begun yet, playback when the video was already playing.
detailsThe underlying error detail as reported by the streaming library or the browser.
httpCodeThe HTTP status of the failed request, when the failure came from a network response.
extraDetailsA JSON string with additional context, including recoveredErrors — the number of errors recovered in this view.

The reasons and their codes are grouped by the nature of the failure: 1xx the source could not be reached, 2xx the content was unusable, 3xx the browser could not decode it, 4xx encryption or DRM, 5xx the environment or anything else.

REASONCODEMEANING
fileMissing101No source URL was provided for the video.
fileUnreachable102The manifest or file could not be loaded.
levelUnreachable103A quality rendition could not be loaded.
preparingFailed104The video never became available while the preparing screen was polling.
failoverExhausted105Every configured stream was tried and none of them played.
networkError106A network failure without a more specific reason.
manifestEmpty201The manifest loaded but contained no streams.
streamEmpty202The stream loaded but contained no segments.
segmentError203A segment failed to load or parse.
codecUnsupported301The browser cannot decode the codecs in the stream.
decodeError302The browser failed to decode the media.
mediaRecoveryExhausted303Media recovery was attempted repeatedly and playback still did not resume.
keyError401An encryption key could not be loaded or applied.
drmError402The DRM license could not be obtained or was rejected.
browserUnsupported501The browser cannot play the source at all.
playRejected502The browser rejected the play request for a reason other than its autoplay policy.
otherError503An unrecoverable failure that fits none of the above.

errorRecovered reports recoveryReason (networkError, mediaError, bufferStall or otherError) together with the recoveryMethod that worked: streamSwitch, recoverMediaError, codecSwap, levelDrop or retry.

note

Live streams keep retrying instead of giving up on network failures, so the reasons a live stream can report are not the same as the ones a VOD video can report. When you build health dashboards, split them on isLive — the two are not comparable. The interrupted and recovered events in Player State Events cover live streams that break and come back while already playing.

Ad Events

EVENTDESCRIPTION
adClickVAST and IMA. Fired whenever a user clicks an ad to be redirected to its landing page.
adCompleteVAST and IMA. Fired whenever an ad has completed playback.
adErrorVAST and IMA. Fired whenever an error prevents the ad from playing.
adImpressionThe time indicated by the video element's currentTime attribute has changed.
adMuteTriggered when the player has gone in or out of a mute state during ad played.
adPauseFired whenever an ad is paused.
adPlayFired whenever an ad starts playing or when an ad is unpaused.
adSkippableFired the instant the ad can be skipped.
adSkippedVAST and IMA. Fired whenever an ad has been skipped.
adTimeFired while ad playback is in progress.
analytic-ad-25%-completedFired when the ad is quarter-way completed.
analytic-ad-50%-completedFired when the ad is halfway completed.
analytic-ad-75%-completedFired when the ad is a quarter away from being completed.

Analytics Events

EVENTDESCRIPTION
video-completedFired when the video is completed.
video-startedFired when the video starts.
video-stateFired every 10 seconds. Its duty is to check whether the video at the moment is paused, playing, whether it is muted or not, its volume etc.
analytics-25%-completedFired when the video is quarter-way completed.
analytics-50%-completedFired when the video is halfway completed.
analytics-75%-completedFired when the video is a quarter away from being completed.
twenty-viewFired once 20 seconds of the video have been watched.
true-viewFired when the view is counted as a true view, meaning the viewer interacted with the player.
embed-loadedFired when the player embed is loaded on the page.
watchedtimeFired with the accumulated watch time of the current view.

All Events

You can setup a listener on all events for a specific player, by listening on vp-event events, and get all properties for a specified event based on its name eventName property:

vpPlayer().on("vp-event", (e) => {
// Check for specific eventName
if (e.eventName == "play") {
console.log("Event play was just triggered on VP Player events");
}
});