The PSDK provides support for displaying banner ads.
To display banner ads:
- (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];
}
}
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMediaPlayerAdClick:)
name:PTMediaPlayerAdClickNotification object:self.player];
- (void) onMediaPlayerAdClick:(NSNotification *) notification {
NSString *url = [notification.userInfo objectForKey:PTMediaPlayerAdClickURLKey];
if (url != nil) {
[self openBrowser:[NSURL URLWithString:url]];
}
}