Overview
Server-Side Ad Insertion (SSAI) allows you to embed ads into your videos so that they can't be blocked by ad blockers in the browser. Dynamic Delivery is the next generation ingest and delivery system which reduces your storage footprint and dynamically packages media. Learn more about using Dynamic Delivery for your videos.
SSAI works with both DRM and non-DRM content.

To play server-side ads with your video content stored in Video Cloud, follow these steps:
Create an ad configuration
The ad configuration defines various aspects of SSAI playback, including a URL to your Video Multiple Ad Playlist (VMAP) file, beacons, and other configurations. For now, you must contact your Brightcove account manager to create your ad configuration.
Android implementation
Follow these steps within your app to get your ad configuration and play your video:
- Include the Once UX plugin in your app, as shown in the Basic Once UX Player sample. This will be the starting point for your app. Notice that the plugin uses a companion ad container.
- In Android Studio, open your MainActivity.java file.
- Comment out or delete the following code:
private String onceUxAdDataUrl = "http://once.unicornmedia.com/now/ads/vmap/od/auto/c501c3ee-7f1c-4020-aa6d-0b1ef0bbd4a9/202ef8bb-0d9d-4f6f-bd18-f45aa3010fe6/8a146f45-9fac-462e-a111-de60ec96198b/content.once"; ... plugin.processVideo(onceUxAdDataUrl);
- Define constants for your account id, policy key, video id, and your ad configuration id.
private String accountId = "your account id"; private String policyKey = "your policy key"; private String videoId = "your video id"; private String adConfigId = "your ad configuration id";
- In the
onCreate
method, set the query parameter value to your ad configuration id.Map<String, String> parameters = new HashMap<>(); parameters.put("ad_config_id", adConfigId);
- Create an instance of the catalog service, which provides asynchronous methods for retrieving data from the Playback API.
Catalog catalog = new Catalog(brightcoveVideoView.getEventEmitter(), accountId, policyKey);
- Call the catalog service to retrieve your video along with your ad configuration from the Playback API. Start video playback with your specified ads.
catalog.findVideoByID(videoId, null, parameters, new VideoListener() { @Override public void onVideo(Video video) { try { // The OnceUX plugin will look for a VMAP URL in the video object properties. // If valid, it will play the video. plugin.processVideo(video); } catch (NoSourceFoundException e) { // If NoSourceFoundException is thrown it means a suitable VMAP URL was not found. // You can try to play it on a regular view, brightcoveVideoView.add(video); } } });
Android MainActivity file
iOS implementation
Follow these steps within your app to get your ad configuration and play your video:
- Include the Once UX plugin in your app, as shown in the Basic Once UX Player sample. This will be the starting point for your app. Notice that the storyboard contains the definitions for the
videoContainerView
and thecompanionSlotContainerView
. - In Xcode, open your ViewController.m file.
- Comment out or delete the following code:
static NSString *kViewControllerVideoURLString = @"http://onceux.unicornmedia.com/now/ads/vmap/od/auto/c6589dd5-8f31-4ae3-8a5f-a54ca3d7c973/632f6399-9e87-4ce2-a7c0-39209be2b5d0/bee45a63-71ea-4a20-800f-b67091867eeb/content.once"; ... // Create video BCOVVideo *video = [BCOVVideo videoWithURL:[NSURL URLWithString:kViewControllerVideoURLString]]; [self.controller setVideos:@[video]];
- Define constants for your account id, policy key, video id, and your ad configuration id.
static NSString *accountId = @"your account id"; static NSString *policyKey = @"your policy key"; static NSString *videoId = @"your video id"; static NSString *adConfigId = @"your ad configuration id";
- Define the
BCOVPlaybackService
class, which provides asynchronous methods for retrieving data from the Playback API.@interface ViewController () <BCOVPlaybackControllerDelegate> @property (nonatomic, strong) id<BCOVPlaybackController> controller; @property (nonatomic, strong) BCOVPlaybackService *playbackService; @property (nonatomic) BCOVPUIPlayerView *playerView; @property (weak, nonatomic) IBOutlet UIView *videoContainerView; @property (weak, nonatomic) IBOutlet UIView *companionSlotContainerView; @end
- In the
viewDidLoad
method, set the query parameter value to your ad configuration id.NSDictionary *queryParameters = @{ @"ad_config_id" : adConfigId };
- Create an instance of the
BCOVPlaybackService
.self.playbackService = [[BCOVPlaybackService alloc] initWithAccountId:accountId policyKey:policyKey];
- Call the
playbackService
to retrieve your video along with your ad configuration from the Playback API. Start video playback with your specified ads.[self.playbackService findVideoWithVideoID:videoId parameters:queryParameters completion:^(BCOVVideo *video, NSDictionary *jsonResponse, NSError *error) { { if (error == nil) { // play it. [self.controller setVideos: @[ video ]]; } else { NSLog (@"Error! Playback Service says: %@", error.localizedDescription); } } }];
iOS ViewController using Objective-C
iOS ViewController using Swift
tvOS implementation
Follow these steps within your app to get your ad configuration and play your video:
- Start with the Basic Once UX Player for tvOS sample written in Swift.
-
Either delete or comment out the code in the
VideoConfig.swift
file. - In Xcode, open your ViewController.m file.
- Define constants for your account id, policy key, video id, and your ad configuration id.
struct VideoConfig { static let kAccountId = "your account id" static let kPolicyKey = "your policy key"; static let kVideoId = "your video id" static let kAdConfigId = "your ad configuration id" }
- Create an instance of the
BCOVPlaybackService
.let playbackService = BCOVPlaybackService(accountId: VideoConfig.kAccountId, policyKey: VideoConfig.kPolicyKey)
- In the
requestContentFromPlaybackService()
method, set the query parameter value to your ad configuration id.let queryParameters = ["ad_config_id": VideoConfig.kAdConfigId]
- Call the
playbackService
to retrieve your video along with your ad configuration from the Playback API. Start video playback with your specified ads.playbackService?.findVideo(withVideoID: VideoConfig.kVideoId, parameters: queryParameters) { (video: BCOVVideo?, jsonResponse: [AnyHashable: Any]?, error: Error?) -> Void in if let v = video { // since "isAutoPlay" is true, setVideos will begin playing the content self.playbackController?.setVideos([v] as NSArray) } else { print("ViewController Debug - Error retrieving video: \(error?.localizedDescription ?? "unknown error")") } }
tvOS ViewController using Swift
tvOS ViewController using Swift + FairPlay
Playing a video with ads
Any video that you retrieve from Video Cloud that has been ingested with Dynamic Delivery, will include the ads specified in the VMAP file in your ad configuration.