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 = new SVSAdPlayerConfiguration();

// Disable ad break autoplay
adPlayerConfiguration.getPublisherOptions().setEnableAdBreakAutoplay(false);
		

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 the SVSAdManagerListener.onAdBreakEvent() method (of any installed SVSAdManagerListener) with the SVSAdBreakEvent.EVENT_TYPE_AD_BREAK_READY event.
From that point on, the SVSAdManager enters in an idle state, waiting for you to call the new SVSAdManager.startAdBreak() method to proceed and actually start and display the ad break.


// Creating the SVSAdManager instance
SVSAdManager adManager = new SVSAdManager(
	this,
	adPlacement,
	adRules,
	adPlayerConfiguration,
	contentData
);

// Define the duration of the bumper
static final int BUMPER_DURATION = 3000;

// Set the SVSAdManager's listener
adManager.addAdManagerListener(new SVSAdManager.AdManagerListener() {
	@Override
	public void onAdBreakEventListener(@NonNull SVSAdBreakEvent adBreakEvent) {
		Handler handler = new Handler(Looper.getMainLooper());

		switch (adBreakEvent.getEventType()) {
			case SVSAdBreakEvent.EVENT_TYPE_AD_BREAK_READY:
				// The ad break is ready. Pause your content player yourself.
				pauseContentPlayer();

				// Display the ad break begin bumper. Here it is a ImageView, can be whatever you want.
				adBreakBeginBumper.setVisibility(View.VISIBLE);

				// Then, once the bumper duration elapsed
				handler.postDelayed(new Runnable() {
					@Override
					public void run() {
						// Hide the bumper
						adBreakBeginBumper.setVisibility(View.GONE);

						// Start the ad break
						adManager.startAdBreak();
					}
				}, BUMPER_DURATION);

				break;

			default:
				break;
		}
	}

	// ...
});
		

When to display the "after ad break" bumper?

Independently from the enableAdBreakAutoplay option value, the SVSAdManager always signal that the ad break is over by calling the SVSAdManagerListener.onAdBreakEvent() method (of any installed SVSAdManagerListener) with the SVSAdBreakEvent.EVENT_TYPE_AD_BREAK_COMPLETED event.

With the enableAdBreakAutoplay option disabled, the SVSAdManager enters in an idle state once the event EVENT_TYPE_AD_BREAK_COMPLETED is sent, waiting for you to call the new SVSAdManager.resumeContent() method to proceed and resume the content video playback.


// Creating the SVSAdManager instance
SVSAdManager adManager = new SVSAdManager(
	this,
	adPlacement,
	adRules,
	adPlayerConfiguration,
	contentData
);

// Set the SVSAdManager's listener
adManager.addAdManagerListener(new SVSAdManager.AdManagerListener() {

// Define the duration of the bumper
static final int BUMPER_DURATION = 3000;

@Override
public void onAdBreakEventListener(@NonNull SVSAdBreakEvent adBreakEvent) {
	Handler handler = new Handler(Looper.getMainLooper());

	switch (adBreakEvent.getEventType()) {
		case SVSAdBreakEvent.EVENT_TYPE_AD_BREAK_READY:
			// The ad break is ready. Pause your content player yourself.
			pauseContentPlayer();

			// Display the ad break begin bumper. Here it is a ImageView, can be whatever you want.
			adBreakBeginBumper.setVisibility(View.VISIBLE);

			// Then, once the bumper duration elapsed
			handler.postDelayed(new Runnable() {
				@Override
				public void run() {
					// Hide the bumper
					adBreakBeginBumper.setVisibility(View.GONE);

					// Start the ad break
					adManager.startAdBreak();
				}
			}, BUMPER_DURATION);

			break;

		case SVSAdBreakEvent.EVENT_TYPE_AD_BREAK_COMPLETED:
		  // The ad break is now over. Display your ad break end bumper.
			adBreakEndBumper.setVisibility(View.VISIBLE);

			// Then, once the bumper duration elapsed
			handler.postDelayed(new Runnable() {
				@Override
				public void run() {
					// Hide the bumper
					adBreakEndBumper.setVisibility(View.GONE);

					// Resume the SDK
					adManager.resumeContent();
				}
			}, BUMPER_DURATION);
			break;

		default:
			break;
	}
}

	// ...
});
		

For more details, check the samples.