Integrating IMA Client Side with Brightcove Web & Smart TV SDK

This document provides detailed instructions on integrating Interactive Media Ads (IMA) Client Side with the Brightcove Web & Smart TV SDK.

Overview

IMA Client-Side allows for the easy integration of video advertising into your media players built with the Brightcove Web & Smart TV SDK. The IMA3 integration facilitates pre-roll, mid-roll, and post-roll ad placements, as well as sophisticated ad management capabilities.

Prerequisites

  • A Brightcove account with access to Video Cloud.

  • The Brightcove Web & Smart TV SDK installed in your project.

  • Access to the Google IMA SDK resources and an Ad Manager account.

Usage Example

  1. Import the Player (with UI) class from the Brightcove SDK.

    import { Player, IntegrationsManager } from '@brightcove/web-sdk/ui';
                
  2. Import the IMA Client-Side integration class from the Brightcove SDK.

    import { ImaClientSideIntegrationFactory } from '@brightcove/web-sdk/integrations/imaClientSide';
                
  3. Import the ImaClientSide integration CSS from the Brightcove SDK.

    import '@brightcove/web-sdk/integrations/imaClientSide/styles';
                
  4. Setup ima-client-side integration.

    IntegrationsManager.registerImaClientSideIntegrationFactory(ImaClientSideIntegrationFactory);
                
  5. Create and Configure the Player.

    const player = new Player({accountId:'<account-id>'});
    
     player.updateConfiguration({
       integrations: {
         imaClientSide: {
           serverUrl: '<ad-tag-url>',
           requestMode: 'onload',
           hardTiemouts: false,
           // etc
         },
       },
     });
  6. Attach the player to a mount root (DOM element in the page):

    const root = document.querySelector('#player-mount-root');
     player.attach(root);
                
  7. Access the IMA Client Side Integration API via the IntegrationsManager:

    const { imaClientSideIntegration } = player.getIntegrationsManager();
                
  8. Call CSAI-specific methods

    imaClientSideIntegration.isVpaid();
                

Configuration Summary

This section provides detailed information about the various configuration options available for Client-Side Ad Insertion (CSAI) when using the Web & Smart TV SDK.

Configuration Option Type Default Description
sdkUrl string https://imasdk.googleapis.com/js/sdkloader/ima3.js The URL to load the IMA3 SDK.
serverUrl string https://pubads.g.doubleclick.net/gampad/ads? sz=400x300&iu=%2F6062%2Fiab_vast_samples &ciu_szs=300x250%2C728x90&gdfp_req=1&env=vp &output=xml_vast2&unviewed_position_start=1 &url=[referrer_url]&correlator=[timestamp] &cust_params=iab_vast_samples%3Dlinear' URL of the ad server from which ads will be requested.
requestMode 'onload' | 'onplay' | 'ondemand' | 'once' 'onload' Defines when the ad requests should be made.
hardTimeouts boolean true If set to true, ads that take too long to load will be abandoned.
showVpaidControls boolean false Determines whether custom player controls for VPAID ads should be displayed.
clickTrackingElement HTMLElement | undefined undefined Specifies the alternative video ad click element. If undefined, the IMA SDK handles clicks.
postRollTimeout number same as timeout Timeout setting for post-roll ads in videojs-contrib-ads. Overrides the default timeout value.
preRollTimeout number same as timeout Timeout setting for pre-roll ads in videojs-contrib-ads. Overrides the default timeout value.
useMediaCuePoints boolean false Enables the use of Video Cloud ad cue points to trigger ads.
vpaidMode string undefined Specifies the VPAID 2 mode for the IMA HTML5 SDK. Defaults to the SDK's current setting, which is ENABLED.

Public Methods Summary

Method Description Parameters Parameter Type Returns
getAdDisplayContainer Get the active AdDisplayContainer instance where ads are displayed. None N/A AdDisplayContainer | null
replaceMacroVariablesFor Replace macro variables in a provided url. For list of supported macros, please see: url string string
getAdsLoader Returns the AdsLoader instance responsible for loading the ads. None N/A AdsLoader | null
getAdsManager Returns the AdsManager instance which manages the playback of ads. None N/A AdsManager | null
requestAd Makes an ad request using the provided ad request URL. adRequestUrl string void
getCurrentAd Returns the currently playing ad. None N/A Ad | null
isVpaid Checks if the current ad is a VPAID (Video Player Ad-Serving Interface Definition) ad. None N/A boolean
setAdsRenderingSettings Sets the rendering settings for ads. adsRenderingSettings AdsRenderingSettings void

Event Summary

Event Name Attribute Description
imaClientSideAdClick Readonly Triggered when an ad is clicked by the user.
imaClientSideAdComplete Readonly Triggered when an ad playback completes.
imaClientSideAdError Readonly Triggered when there is an error in ad playback.
imaClientSideAdStarted Readonly Triggered when an ad starts playing.
imaClientSideAdsLoad Readonly Triggered when ads are loaded and ready to play.
imaClientSideAdsPodEnded Readonly Triggered when an ad pod (a group of ads) finishes playing.
imaClientSideAdsPodStarted Readonly Triggered when an ad pod (a group of ads) starts playing.
imaClientSideAdsRequest Readonly Triggered when an ad request is made to the server.
imaClientSideAllAdsCompleted Readonly Triggered when all scheduled ads have completed playback.
imaClientSideFirstQuartile Readonly Triggered when the ad playback reaches the first quartile.
imaClientSideMidPoint Readonly Triggered when the ad playback reaches the midpoint.
imaClientSidePaused Readonly Triggered when an ad is paused by the user.
imaClientSideResumed Readonly Triggered when a paused ad is resumed by the user.
imaClientSideSdkLoaded Readonly Triggered when the IMA SDK is fully loaded and ready.
imaClientSideSkipped Readonly Triggered when an ad is skipped by the user.
imaClientSideThirdQuartile Readonly Triggered when the ad playback reaches the third quartile.
imaClientSideVolumeChanged Readonly Triggered when the ad volume is changed by the user.

Error Summary

Error Name Description
AdsBeforePrerollError Error encountered before the preroll ad starts.
AdsPrerollError Error during the preroll ad.
AdsMidrollError Error during the midroll ad.
AdsPostrollError Error during the postroll ad.
AdsMacroReplacementError Error in replacing macros in the ad URL or tracking events.
AdsResumeContentError Error while resuming the content after an ad break.
ImaVmapCancelledError VMAP ad playlist request was canceled.
ImaAdsManagerStartError Error when starting the IMA Ads Manager.
ImaInvalidVpaidModeError Invalid VPAID mode set.
ImaSdkLoadError Error loading the IMA SDK.
ImaInvalidCueError Error due to an invalid cue point in the ad break.
ImaCueParsingError Error parsing the ad cue points.