TVSDK supports companion banner ads, which are ads that accompany a linear ad and often remain on the page after the linear ad ends. Your application is responsible for displaying the companion banners that are provided with a linear ad.
When displaying companion ads, follow these recommendations:
Attempt to present as many of a video ad’s companion banner ads as will fit in your player’s layout.
Present a companion banner only if you have a location that exactly matches its specified height and width.
Do not resize the banner.
Present the companion banner(s) as soon as possible after the ad begins.
Do not overlay the main ad/video container with companion banners.
Continue to display companion banners after the ad ends.
The standard is to display each companion banner until you have a replacement for this banner.
The content of a PTAdAsset describes a companion banner.
The PTMediaPlayerAdStartedNotification
notification returns a PTAd
instance that contains a companionAssets
property (array of PtAdAsset
).
Each PtAdAsset
provides information about displaying the asset.
Available information | Description |
---|---|
width | Width of the companion banner in pixels. |
height | Height of the companion banner in pixels. |
resource type | The resource type for this companion banner:
|
data | The data of the type that is specified by resourceType for this companion banner. |
To display banner ads, you need to create banner instances and allow TVSDK to listen for ad-related events.
TVSDK provides a list of companion banner ads that are associated with a linear ad through the PTMediaPlayerAdPlayStartedNotification
notification event.
Manifests can specify companion banner ads by:
For each companion ad, TVSDK indicates which types are available for your application.
Create a PTAdBannerView
instance for each companion ad slot on your page.
Ensure that the following information has been provided:
Add an observer for the PTMediaPlayerAdStartedNotification
that does the following:
Clears existing ads in the banner instance.
Gets the list of companion ads from Ad.getCompanionAssets
PTAd.companionAssets
.
If the list of companion ads is not empty, iterate over the list for banner instances.
Each banner instance ( a PTAdAsset
) contains information, such as width, height, resource type (html, iframe, or static), and data that is required to display the companion banner.
If a video ad has no companion ads booked with it, the list of companion assets contains no data for that video ad.
To show a standalone display ad, add the logic to your script to run a normal DFP (DoubleClick for Publishers) display ad tag in the appropriate banner instance.
Sends the banner information to a function on your page that displays the banners in an appropriate location.
This is usually a div
, and your function uses the div ID
to display the banner. For example:
- (void) onMediaPlayerAdPlayStarted:(NSNotification *) notification {
_currentAd = [notification.userInfo objectForKey:PTMediaPlayerAdKey];
if (_currentAd != nil) {
[self removeAllBanners]; // remove any existing PTAdBannerView views
// banners
if (_currentAd.companionAssets && _currentAd.companionAssets.count > 0) {
PTAdAsset *bannerAsset = [_currentAd.companionAssets objectAtIndex:0];
PTAdBannerView *bannerView = [[PTAdBannerView alloc] initWithAsset:bannerAsset];
bannerView.player = self.player;
bannerView.delegate = self;
bannerView.frame = CGRectMake(0.0, 0.0, bannerAsset.width, bannerAsset.height);
[_adBannerView.bannerView addSubview:bannerView];
}
}
}