Advanced integration

More advanced integration examples.

  1. Bumper management
    1. Disabling the ad break autoplay
    2. When to display the "before ad break" bumper?
    3. When to display the "after ad break" bumper?

Bumper management

As a publisher, you may want to display bumpers to warn the user before and after ad breaks, for legal reason or not. With the Smart Instream SDK 7.13.0, you are now able to do this by following a specific integration.

To do so, we introduced a new option to disable the ad break autoplay (enabled by default), and let you decide when to start ad breaks, hence giving you the opportunity to display any kind of bumper you want before and after ad breaks.

Disabling the ad break autoplay

This new option is called enableAdBreakAutoplay and was added to the publisher options model: SVSAdPlayerConfigurationPublisherOptions.

enableAdBreakAutoplay is true by default. You have to explicitly set it to false to disable the ad break autoplay as follows:


//////////////////////////////////////////////////////////////////////
// AD PLAYER CONFIGURATION
//////////////////////////////////////////////////////////////////////

// Create a new SVSAdPlayerConfiguration.
SVSAdPlayerConfiguration *adPlayerConfiguration = [[SVSAdPlayerConfiguration alloc] init];

// Disable ad break autoplay
adPlayerConfiguration.publisherOptions.enableAdBreakAutoplay = NO;
		

When to display the "before ad break" bumper?

When the enableAdBreakAutoplay option is disabled, the SVSAdManager will not start the ad break playback, but instead will notify the application that an ad break is ready by calling a newly added delegate method adManager:isReadyToStartAdBreak: in the SVSAdManagerDelegate protocol.
From that point on, the SVSAdManager enters in an idle state, waiting for you to call its new startAdBreak method to proceed and actually start and display the ad break.


// Implementation of the new SVSAdManagerDelegate method
- adManager:(SVSAdManager *)adManager isReadyToStartAdBreak:(SVSAdBreakType)adBreakType {
	// Manually pause content here
	[self pauseContent];

	// Then display the ad break begin bumper.
	[self displayBeginBumper];

	dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(BUMPER_DURATION * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
		// After some delay, actually start the ad break
		[self.adManager startAdBreak];
	});
}

- (void)adManager:(SVSAdManager *)adManager didStartAdBreak:(SVSAdBreakType)adBreakType {
	// Make sure to hide the bumper once the ad break started.
	[self hideBeginBumper];
}
		

When to display the "after ad break" bumper?

To display the "after ad break" bumper, you can relay on 2 already existing delegate methods: adManager:didFinishAdBreak:numberOfAds:duration:error: and adManagerDidRequestToResumeContentPlayer:forAdBreak:.

To avoid displaying a bumper after a failing or an empty ad break, be sure to check the numberOfAdsPlayed parameter to decide whether you should display the bumper or not. Moreover, in the sample, we advise you to handle the bumper display in the adManagerDidRequestToResumeContentPlayer:forAdBreak: delegate method, however this method is not called in case of postroll, as the content if already over. In that particular case, you should handle the bumper display within adManager:didFinishAdBreak:numberOfAds:duration:error: delegate method.


// Implementation of the new SVSAdManagerDelegate method
- adManager:(SVSAdManager *)adManager isReadyToStartAdBreak:(SVSAdBreakType)adBreakType {
	// Manually pause content here
	[self pauseContent];

	// Then display the ad break begin bumper.
	[self displayBeginBumper];

	dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(BUMPER_DURATION * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
		// After some delay, actually start the ad break
		[self.adManager startAdBreak];
	});
}

- (void)adManager:(SVSAdManager *)adManager didStartAdBreak:(SVSAdBreakType)adBreakType {
	// Make sure to hide the bumper once the ad break started.
	[self hideBeginBumper];
}

- (void)adManager:(SVSAdManager *)adManager didFinishAdBreak:(SVSAdBreakType)adBreakType numberOfAds:(NSInteger)numberOfAdsPlayed duration:(NSTimeInterval)duration error:(NSError *)error {
	if (adBreakType == SVSAdBreakTypePostroll && numerOfAdsPlayed > 0) {
		// Display the postroll end bumper
		[self displayEndBumper];

		// After some delay, hide the bumper.
		dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(BUMPER_DURATION * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
			[self hideEndBumper];
		});
	} else {
		// Here decide weither you should display end bumper or not, depending on the number of ads played.
		self.shouldDisplayEndBumper = numberOfAdsPlayed > 0;
	}
}

- (void)adManagerDidRequestToResumeContentPlayer:(SVSAdManager *)adManager forAdBreak:(SVSAdBreakType)adBreakType {
	// Check if we should display the end bumper
	if (self.shouldDisplayEndBumper) {

		// Reset flag
		self.shouldDisplayEndBumper = NO;

		// Display the bumper
		[self displayEndBumper];

		// After some delay, hide the bumper and resume the content.
		dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(BUMPER_DURATION * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
			[self hideEndBumper];
			[self resumeContent];
		});

	} else {
		// Else resume the content directly.
		[self resumeContent];
	}
}
		

For more details, check the samples.