relevantDigital.loadVideoUrls()

This function is used for obtaining URLs to VAST XML documents that should be supplied to the video player for instream video.

The loadVideoUrls() function waits until loading is completed for a specified set of video slots. It won't actually start any loading, instead it waits for a corresponding call to relevantDigital.loadPrebid() has been completed.

The order or calling loadPrebid() and loadVideoUrls() doesn't matter, but loadVideoUrls() won't complete until after the corresponding Prebid auction is complete.

In case loadVideoUrls() is called multiple times for the same slots, then only the first call will complete when a single loadPrebid() call is done. 

For more explanations along with a complete example on how to use instream video with Google Ad Manager - please read this article: Instream video with HBM and GAM

Notice: This functionality is currently only available when using Google Ad Manager as ad server.

Parameters

relevantDigital.loadVideoUrls(ids, cb, settings)

  • ids - the ids of the VideoSlot elements previously created with relevantDigital.defineVideoSlot(). To get the id of a VideoSlot, use the [videoSlot].getSlotElementId() function
  • cb(urls) - The callback function that will receive the array of URLs to VAST XML documents. urls can then be supplied to the video player in a player specific way.
  • settings - optional settings.
    onBuildVideoUrl - callback which makes it possible to customize the settings object that will be provided to pbjs.adServers.dfp.buildVideoUrl().

Example

window.relevantDigital = window.relevantDigital || {};
relevantDigital.cmd = relevantDigital.cmd || [];
relevantDigital.cmd.push(() => {
  const videoSlots = relevantDigital.defineVideoSlots([
      {
path: '/12345/articles/pre_roll',
id: 'preroll_1',
custParams: { 'section': 'articles' },
},
    {
path: '/12345/articles/pre_roll',
id: 'preroll_2',
         custParams: { 'section': 'articles' },
         },
  ]);
    

  // Call relevantDigital.loadPrebid() "as normal"
  relevantDigital.loadPrebid({ ... });
    
  // Get the URLs with VAST XML that should be used with the video player
relevantDigital.loadVideoUrls(['preroll_1', 'preroll_2'], (vastUrls, datas) => {
console.info('VAST URLs:', vastUrls);
// TODO: Invoke video player here
});
});

When using an adserver other than GAM

The vastUrls returned are intended for Google Ad Manager. If you're using another adserver and/or needs more information about the returned bids - you can use the datas parameter supplied to the callback function.

relevantDigital.loadVideoUrls(['preroll_1', 'preroll_2'], (vastUrls, datas) => {
datas.forEach(({ unitData }) => {
        const highestBid = unitData.getHighestBid();
      if (highestBid) {
           console.info('Got bid for placement: ', unitData.slot.getAdUnitPath());
          console.info('Targeting key-values: ', highestBid.adserverTargeting);
console.info('VAST URL: ', highestBid.vastUrl);
            console.info('VAST XML: ', highestBid.vastXml);

} else {
console.info('No bid for placement: ', unitData.slot.getAdUnitPath());
}
});
});