Skip to main content

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:

PropertyTypeRequeired / OptionalDescription
contentUrlURLRequiredThe playback URL for the content if adMetaDataUrl is availeble and parsing the vMap also holds contentUrl will replace this property value.
adMetaDataUrlStringOptionalThe VMAP URL to fetch ad metadata information and thumbnail keyframe data for the content.
adPlaybackPolicyAdPlaybackPolicyOptionalA policy handler to customize ad playback.
palConfigurationPALSessionConfigurationOptionalPAL 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>) -> VoidCallbackA 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
}
}
note

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 AvailebleAdMetaDataUrl AvailablePalNonceHolder AvailebleVOD/LIVEDescription
YesYesYesVODAdd PALNonceKey with AdMetaURL and Content URL will be replace after parsing AdMetaURL(VMap).
YesYesNOVODContent URL will be replace after parsing AdMetaURL(VMap).
YesNoYesBoth VOD/LIVEAdd PALNonceKey to content URL
YesNoNoBoth VOD/LIVEMostly 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:

PropertyTypeDescription
thumbnailList[WebVTTModel]A list of keyframe data for the player content
palClientPALSessionClientTo 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.

PropertyTypeDescription
positionAdPositionThe position of the ad break, can be on of preroll, midroll or postroll
startTimeTimeIntervalThe start position in seconds
durationTimeIntervalThe duration of the ad break, in seconds
totalAdsIntTotal number of adverts in the ad break

Represents an advert object.

PropertyTypeDescription
adIdStringThe identifier of the advert
sequenceIntThe sequence of the advert
durationTimeIntervalThe duration of the advert in seconds
isSkippableBoolIndicates if the ad is skippable
adBreakAdBreakThe ad break which the advert belongs to
vastPropertiesVASTPropertiesRepresents key VAST properties to be shared with all registered verification providers.
VASTProperties

Represents a VAST properties object.

PropertyTypeDescription
skipOffsetTimeIntervalThe number of seconds before the skip button is presented
isAutoPlayBoolWhether the player will auto-play content
adPositionAdPositionThe position of the ad break, can be on of preroll, midroll or postroll
adSystemStringThe source ad server of the advert
AdTitleStringThe common name of the advert
adServingIdstringAn identifier used to compare impression-level data across systems
creativeIdStringCreativeId of the advert
categoryStringCategory of the advert content
descriptionStringThe longer description of the advert
advertiserStringAdvertiser name
pricingStringPricing element of the advert
surveyStringAn URI to any resource file having to do with collecting survey data
expiresStringNumber of seconds in which the ad is valid for execution
industryIconsArray of IndustryIconThe list of IndustryIcon instances
extensionsExtensionsThe custom VAST extensions properties