Migrating to videojs-contrib-ads 6.0.0
Version 6 of videojs-contrib-ads includes a major refactor and cleanup of the state management logic.
Migration
- Timeouts have a more intuitive behavior. See the “Timeout behavior changes” section below for more information.
- Ended events are no longer delayed by 1 second.
- Ended events due to an ad ending will no longer be allowed to replace the ended event that is triggered by linear ad mode ending. Ad plugins must not emit ended events after the end of linear ad mode.
- There will no longer be a
contentendedevent when content ends after the first time content ends. ads.statehas been removed. Methods have been added to replace state checks, such asads.isInAdMode(). See the documentation for a list of available methods.ads._statehas been added, but it is not compatible with the oldads.stateand should not be inspected by ad plugins.- The event parameter
triggereventhas been removed. It is unlikely that ad plugins used it, but any usage must be migrated. - We no longer trigger a
readyforprerollevent after receiving anoprerollevent. - adTimeoutTimeout has been removed. It was not part of the documented interface, but make note if your ad plugin inspected it.
- There is no longer a snapshot object while checking for postrolls. Now a snapshot is only taken when a postroll ad break actually begins.
- The
contentplaybackevent (removed in 4.0.0, re-added as deprecated in 4.1.1), has been removed. Use theplayingevent instead. - The
adplayingbehavior is an implementation detail and has changed in this update. Theadplayingevent is no longer guaranteed to happen once per ad break. It is not intended to be used to detect the beginning of an ad break. Theads-pod-startedevent should be used instead. Theads-ad-startedevent can be used to detect the start of an individual ad in an ad break. There will be multipleads-ad-startedevents corresponding to each ad in the ad break.
Deprecation
Deprecated interfaces will be removed in a future major version update.
contentupdateis now deprecated. It has been replaced bycontentchanged.contentupdatewas never intended to fire for the initial source, but over time its behavior eroded. To make migration easier for anyone who depends on the current behavior, we’re providing a deprecation period and a new event with correct behavior.adscanceledis now deprecated. Instead, usenoprerollandnopostroll.adscanceledwas initially intended to function similarly to calling bothnoprerollandnopostrollbut it was never fully implemented.adserroris now deprecated. Currently this event will skip prerolls when seen before a preroll ad break, skip postrolls if called after contentended and before a postroll ad break, and end linear ad mode if seen during an ad break. It is more declarative for the ad plugin to do these things explicitly withskipLinearAdModeandendLinearAdMode. In the future, this event will not have any special behavior in contrib-ads. Ad plugins may continue to use it for other purposes.
Timeout behavior changes
Previous behavior:
- The
timeoutsetting was the number of milliseconds that we waited foradsreadyafter theplayevent ifadsreadywas not beforeplay. - The
prerollTimeoutsetting was the number of milliseconds we waited forstartLinearAdModeafterreadyforpreroll. It was a separate timeout period aftertimeout. - The
postrollTimeoutsetting was the number of milliseconds we waited forstartLinearAdModeaftercontentended.
Previous Defaults:
- timeout: 5000
- prerollTimeout: 100
- postrollTimeout: 100
New Behavior:
- The
timeoutsetting is now the default setting for all timeouts. It can be overridden byprerollTimeoutand/orpostrollTimeout. prerollTimeoutoverridestimeoutfor the number of milliseconds we wait for a preroll ad (the time betweenplayandstartLinearAdMode).postrollTimeoutoverridestimeoutfor the number of milliseconds we wait for a postroll ad (the time betweencontentendedandstartLinearAdMode).
New Defaults:
- timeout: 5000
- prerollTimeout: no default
- postrollTimeout: no default