CustomAdIntegrationController
public protocol CustomAdIntegrationController
The shared controller for custom ad integrations. Use it to update the state of a custom ad integration.
-
The identifier for this integration, as passed to
Ads.registerServerSideIntegrationorAds.registerClientSideIntegration.Declaration
Swift
var integration: String { get } -
The scheduled ads managed by this integration.
Remark
UseCustomAdIntegrationController.createAdandCustomAdIntegrationController.removeAdto add or remove ads.Declaration
Swift
var ads: [Ad] { get } -
The scheduled ad breaks managed by this integration.
Remark
UseCustomAdIntegrationController.createAdBreakandCustomAdIntegrationController.removeAdBreakto add or remove ad breaks.Declaration
Swift
var adBreaks: [AdBreak] { get } -
Create a new ad.
Remark
The ad will be added to
Ads.scheduledAds.Parameters
paramsThe initial properties to be set on the created ad.
adBreakReturn Value
The created
Adobject. -
Update the playback progression of the given ad.
Remark
The player will fire progression events such as
AdsEventTypes.AD_FIRST_QUARTILE,AdsEventTypes.AD_MIDPOINTandAdsEventTypes.AD_THIRD_QUARTILE.Declaration
Swift
func updateAdProgress(ad: Ad, progress: Double)Parameters
adThe ad to be updated.
progressThe playback progress, as a number between 0 (at the start of the ad) and 1 (at the end of the ad).
-
Begin the given ad.
Remark
The ad will be added to
Ads.currentAds. AnAdsEventTypes.AD_BEGINevent will be fired.Declaration
Swift
func beginAd(ad: Ad)Parameters
adThe
Adthat will begin. -
End the given ad.
Remark
The ad will be removed from
Ads.currentAds. If the ad was currently playing, anAdsEventTypes.AD_ENDevent will be fired.Declaration
Swift
func endAd(ad: Ad)Parameters
adThe
Adthat will end. -
Skip the given ad.
Remark
The ad will be removed from
Ads.currentAds. If the ad was currently playing, anAdsEventTypes.AD_SKIPevent will be fired.Declaration
Swift
func skipAd(ad: Ad)Parameters
adThe
Adthat will be skipped. -
Report that the given ad counts as an impression.
Remark
The player will fire an
AdsEventTypes.AD_IMPRESSIONevent on every call. The call is ignored if the ad has not begun.Declaration
Swift
func reportAdImpression(ad: Ad)Parameters
adThe ad that counts as an impression.
-
Report that the user clicked on the given ad’s click-through, or on one of its companions.
Remark
The player will fire an
AdsEventTypes.AD_CLICKEDevent on every call. The player does not open the click-through; the integration is responsible for that. The ad does not need to be playing, since a companion can stay visible after its ad ended. The call is ignored if the ad was removed.Declaration
Swift
func reportAdClick(ad: Ad)Parameters
adThe ad that was clicked.
-
Remove the given ad.
Remark
The ad will be removed from
Ads.currentAdsandAds.scheduledAds. If the ad was currently playing, it will first be ended.Declaration
Swift
func removeAd(ad: Ad)Parameters
adThe
Adthat will be removed. -
Create a new ad break.
This can be used to indicate where ad breaks can be expected in advance, before populating those ad breaks with ads.
Remark
The ad break will be added to
CustomAdIntegrationController.adBreaksandAds.scheduledAdBreaks.Declaration
Swift
func createAdBreak(params: AdBreakInit) -> AdBreakParameters
paramsThe initial properties to be set on the created ad break.
Return Value
The created
AdBreakobject. -
Update the given ad break.
Declaration
Swift
func updateAdBreak(adBreak: AdBreak, params: AdBreakInit)Parameters
adBreakThe ad break to be updated.
paramsThe properties to be updated on the ad break.
-
End the given ad break.
An ad break begins implicitly when the first of its ads is begun with
CustomAdIntegrationController.beginAd.Remark
Remark:
- Any of its ads that are still playing will first be ended with
CustomAdIntegrationController.endAd. - An
AdsEventTypes.AD_BREAK_ENDand anAdsEventTypes.AD_BREAK_CHANGEevent will be fired. - The ad break stays in
CustomAdIntegrationController.adBreaks, but is removed fromAds.scheduledAdBreaks. Its ads that were not begun stay inAds.scheduledAds. - To remove the ad break, call
CustomAdIntegrationController.removeAdBreakafterwards. This does not end the ad break again. - If one of its remaining ads is begun later, the ad break begins again and is added back to
Ads.scheduledAdBreaks. - If the ad break is not currently playing, this does nothing.
Declaration
Swift
func endAdBreak(adBreak: AdBreak)Parameters
adBreakThe
AdBreakthat will end. - Any of its ads that are still playing will first be ended with
-
Remove the given ad break and all of its ads.
Remark
The ad break will be removed from
CustomAdIntegrationController.adBreaksandAds.scheduledAdBreaks. Any remaining ads in the ad break will be removed.Declaration
Swift
func removeAdBreak(adBreak: AdBreak)Parameters
adBreakThe ad break to be removed.
-
Remove all ads and ad breaks.
Remark
This is a shorthand for callingCustomAdIntegrationController.removeAdBreakon all ad breaks inCustomAdIntegrationController.adBreaks.Declaration
Swift
func removeAllAds() -
Fire an
AdsEventTypes.AD_ERRORevent on the player’sAdsinterface.This does not stop playback.
Declaration
Swift
func error(error: Error)Parameters
errorThe error.
-
Fire a fatal
PlayerEventMap.ERRORevent on the player.This stops playback immediately. Use
THEOplayer.sourceto load a new source.Declaration
Swift
func fatalError(error: Error, code: THEOErrorCode?)Parameters
errorThe error.
codeThe error code. By default, this is set to
THEOErrorCode.AD_ERROR.