Server Side Ad Insertion in FLAdvertisingBrightcove
The FLAdvertisingBrightcove library enables the playback of Brightcove-curated streams with advertisements. To build a Brightcove player, use the FLBrightcoveFactory.buildPlayer
API with the following parameters:
Property | Type | Requeired / Optional | Description |
---|---|---|---|
contentUrl | URL | Required | The playback URL for the content if adMetaDataUrl is availeble and parsing the vMap also holds contentUrl will replace this property value. |
adMetaDataUrl | String | Optional | The VMAP URL to fetch ad metadata information and thumbnail keyframe data for the content. |
adPlaybackPolicy | AdPlaybackPolicy | Optional | A policy handler to customize ad playback. |
palConfiguration | PALSessionConfiguration | Optional | PAL session configuration to load nonce value and attach nonceKey with adMetaDataUrl if availeble or contentUrl. To report player playback start/end events and share click events with GooglePAL. |
completion | (Result<BrightcoveAdPlayer, Error>) -> Void | Callback | A callback that returns either BrightcoveAdPlayer or an VMap failure error. |
let contentUrl: String = // Add your "Content URL"
let vMapUrl: String = // Add your "VMap URL"
let palConfig = // Add your PALSessionConfiguration
// Override default playback policy, provide custom playback policy value if it required.
let playBackPolicy = // Add your AdPlaybackPolicy
FLBrightcoveFactory.buildPlayer(contentUrl: contentUrl, adMetaDataUrl: vMapUrl, adPlaybackPolicy: playBackPolicy, palConfiguration: palConfig) { result in
switch result {
case let .success(player):
// Player reference available here..
case let .failure(error):
// VMap Failure reported here
}
}
if nonce place holder available in contentUrl(playback) or adMetaDataUrl(vMap URL), sdk hold default PAL configuration to get nonce value if not provided pal configuration in buildPlayer API.
Use case for build an BrightcoveAdPlayer.
ContentURL Availeble | AdMetaDataUrl Available | PalNonceHolder Availeble | VOD/LIVE | Description |
---|---|---|---|---|
Yes | Yes | Yes | VOD | Add PALNonceKey with AdMetaURL and Content URL will be replace after parsing AdMetaURL(VMap). |
Yes | Yes | NO | VOD | Content URL will be replace after parsing AdMetaURL(VMap). |
Yes | No | Yes | Both VOD/LIVE | Add PALNonceKey to content URL |
Yes | No | No | Both VOD/LIVE | Mostly this will be for LIVE play back content. |
Wiring Authorization Response
// Need to update
This BrightcoveAdPlayer could be used like conventional player from FLPlayer library for playback.
BrightcoveAdPlayer provides:
Property | Type | Description |
---|---|---|
thumbnailList | [WebVTTModel] | A list of keyframe data for the player content |
palClient | PALSessionClient | To share click events from the client application with GooglePAL |
BrightcoveAdPlayer implements the getThumbnailUrl(for position: Double) -> String? API to fetch thumbnail keyframe data for a specific time in the playback. This is optional, as it can also be done via the client application using the thumbnailList property of BrightcoveAdPlayer.
/// thumbanail url for keyframe of particular playhead position.
let thumbnailUrl = player.getThumbnailUrl(for position: Double)
Listening to Ad Delegate Methods
The client can set adDelegate on ad player and listen to ad events to track the state of ad playback and implement custom UIs. The AdPlayer
invokes the following ad delegate methods:
/// Called on ad playback failure
func adPlayer(ad: Ad?, didFailWith error: Error)
/// Called when cue points are available
func adPlayerDidProvide(cuepoints: [Int])
/// Called on ad break start
func adPlayerDidStart(adBreak: AdBreak)
/// Called on ad start
func adPlayerDidStart(ad: Ad)
/// Called on ad playback progress change
func adPlayer(ad: Ad?, didChange progress: TimeInterval)
/// Called on ad playback buffer state change
func adPlayer(ad: Ad?, didChangeBuffer isBuffering: Bool)
/// Called on occurance of ad track event
func adPlayer(ad: Ad?, didTrack event: AdTrackingEvent)
/// Called on ad end
func adPlayerDidEnd(ad: Ad)
/// Called on ad break end
func adPlayerDidEnd(adBreak: AdBreak)
Ad Metadata
AdBreak
Represents an ad break object.
Property | Type | Description |
---|---|---|
position | AdPosition | The position of the ad break, can be on of preroll , midroll or postroll |
startTime | TimeInterval | The start position in seconds |
duration | TimeInterval | The duration of the ad break, in seconds |
totalAds | Int | Total number of adverts in the ad break |
Ad
Represents an advert object.
Property | Type | Description |
---|---|---|
adId | String | The identifier of the advert |
sequence | Int | The sequence of the advert |
duration | TimeInterval | The duration of the advert in seconds |
isSkippable | Bool | Indicates if the ad is skippable |
adBreak | AdBreak | The ad break which the advert belongs to |
vastProperties | VASTProperties | Represents key VAST properties to be shared with all registered verification providers. |
VASTProperties
Represents a VAST properties object.
Property | Type | Description |
---|---|---|
skipOffset | TimeInterval | The number of seconds before the skip button is presented |
isAutoPlay | Bool | Whether the player will auto-play content |
adPosition | AdPosition | The position of the ad break, can be on of preroll , midroll or postroll |
adSystem | String | The source ad server of the advert |
AdTitle | String | The common name of the advert |
adServingId | string | An identifier used to compare impression-level data across systems |
creativeId | String | CreativeId of the advert |
category | String | Category of the advert content |
description | String | The longer description of the advert |
advertiser | String | Advertiser name |
pricing | String | Pricing element of the advert |
survey | String | An URI to any resource file having to do with collecting survey data |
expires | String | Number of seconds in which the ad is valid for execution |
industryIcons | Array of IndustryIcon | The list of IndustryIcon instances |
extensions | Extensions | The custom VAST extensions properties |