IMA#

Introduction#

The KWIKplayer IMA Plugin integrates the Google Interactive Media Ads (IMA) SDK with KWIKplayer, enabling seamless ad playback in formats such as VAST, VMAP, or ad rules.


Configuration Options#

The plugin provides several configuration options to customize its behavior. Below is a list of the supported options:

OptionTypeDefaultDescription
adLabelstring"Advertisement"Replaces the "Advertisement" text in the ad label.
adLabelNofNstring"of"Replaces the "of" text in the ad label (e.g., 1 of 2).
adTagUrlstringnullURL for fetching a VAST, VMAP, or ad rules response. Overrides adsResponse and adsSchedule.
adsRenderingSettingsobject{}Ads rendering settings as defined in the IMA SDK.
adsResponsestringnullVAST/VMAP/ad rules response used instead of adTagUrl.
adsScheduleobjectnullAd scheduling configuration. Allows VMAP construction automatically.
adsRequestobject{}Ad request properties defined in the IMA SDK.
autoPlayAdBreaksbooleantrueAutomatically plays VMAP/ad rules ad breaks.
contribAdsSettingsobject{}Additional settings for the contrib-ads plugin.
debugbooleanfalseEnables or disables debug mode.
disableAdControlsbooleanfalseHides ad controls (play/pause, volume, fullscreen) during ad playback.
disableCustomPlaybackForIOS10PlusbooleanfalseDisables custom playback on iOS 10+ browsers.
disableFlashAdsbooleanfalseDisables Flash ads.
forceNonLinearFullSlotbooleantrueForces non-linear ads to render as linear fullslot.
localestringnullSets the locale for ad localization.
numRedirectsnumbernullMaximum number of VAST redirects before aborting the ad load.
preventLateAdStartbooleanfalsePrevents ads from starting late after content playback begins.
showControlsForJSAdsbooleantrueDisplays the control bar for VPAID JavaScript ads.
showCountdownbooleantrueShows the ad countdown timer.
vastLoadTimeoutnumber5000Overrides the VAST load timeout in milliseconds for a single wrapper.
vpaidMode"ENABLED" | "DISABLED" | "INSECURE""ENABLED"VPAID mode configuration. Overrides vpaidAllowed.

Usage#

To enable the IMA plugin, include its configuration under the imaPlugin key when initializing KWIKplayer:

const player = window.kwikMotion('my-video', {
  imaPlugin: {
    adTagUrl: 'https://example.com/vast.xml',
    autoPlayAdBreaks: true,
    showCountdown: true,
    debug: false,
  }
})

Ad Scheduling#

The adsSchedule option allows you to define a schedule for preroll, midroll, and postroll ads:

window.initPlayer('my-video', {
  imaPlugin: {
    adsSchedule: {
      preroll: ['https://example.com/preroll.xml'],
      30: ['https://example.com/midroll.xml'], // Midroll at 30 seconds
      postroll: ['https://example.com/postroll.xml'],
    },
  }
})

Events#

The plugin emits various events to help you monitor ad behavior: Key Events

  • ads-ad-started
  • adstart
  • adend
  • adskip
  • adtimeout
  • adsready
  • nopreroll
  • nopostroll
  • contentplay
  • adserror

Example#

player.on('ads-ad-started', () => {
  console.log('Ad started!');
});

Debugging#

Enable debugging to log detailed information about the plugin's behavior:

window.initPlayer('my-video', {
  imaPlugin: {
    debug: true,
  }
})