CEInStreamAD
Characteristics
Three types of in-stream video ads are supported: pre-roll, mid-roll and post-roll.
Pre-roll ads
Pre-roll ads are displayed before the content video. Ads are played once user starts the playback of content video.
Post-roll ads
Post-roll ads are displayed after the content video finished playing. Ads are played once the content video finished playing.
Mid-roll ads
Mid-roll ads are served in the middle of content video at each cue points. Multiple mid-roll ads can be arranged in single video.
Cue points at which to show ads are defined in 3 different policies, Every N Seconds, Fixed Time or Fixed Percentage.
Ad break at each cue point manages duration and number of video ad to be played in 3 different rules, Single, Fixed time or Multi Ad.
Integration
Add Files for InStream Ad Integration
Add CEInStreamAD.h
to app's build target.
Declare InStream Ad
Import
CEInStreamAD.h
Set up
CEInStreamADDelegate
andCEContentProgressProvider
protocol in view controller's extension.Create a CEInStreamAD instance and keep its reference.
Initialize InStream Ad
Initialize CEInStreamAD instance and necessary properties.
Request InStream Ad
startAutoRequestAD
must be called after CEInStreamAD instance is initializedstartAutoRequestAD
shall be called before video content is played, otherwise ad breaks in the beginning of the video, pre-roll ad especially, will be wasted**Please call
startAutoRequestAD
for only one time for each CEInStreamAd instance.**
Implement CEInStreamADDelegate to handle InStream Ad Event
Implement CEContentProgressProvider to update Video Content Status
isContentPlayerReady
,getContentCurrentPosition
andgetContentTotalDuration
must be implemented otherwise InStream ad will not be servedPlease read this carefully: During the time user is seeking the video, app should always return the progress time that user start seeking instead of the current time that user has sought to. Once user stop seeking, please return the progress time that user stopped at.
Release InStream Ad
InStream ad shall at least be released along with the life cycle of video content
Advance Integration
7 properties in total for InStream ad. Properties in CEVideoViewProfile represent different elements on InStream ad UI. (Please refer to diagram above)
CEVideoViewProfileInStreamDefaultProfile
: All elements included and volume on when InStream ad start playingCEVideoViewProfileSilentStart
: Volume off when InStream ad start playing(A)
CEVideoViewProfileSpeaker
: Top left speaker(B)
CEVideoViewProfileAdCount
: Bottom left AdCount(C)
CEVideoViewProfileAdIcon
: Top right ad icon(D)
CEVideoViewProfileCountDown
: Top right count down timer(E)
CEVideoViewProfileSkipButton
: Bottom right skip button
API Reference
Public constructors
Public methods
void
void
void
void
void
void
void
nullable NSArray <NSNumber*> *
int
int
CEMilliSec
CEMilliSec
Public Properties
NSDictionary
Public Constructors
initWithRequestInfo
Instantiates a new InStream ad.
Parameters
info
Request information
adContainer
UIView that ad will be played on
videoViewProfile
CEVideoViewProfile to define elements to be shown on Video ad. CEVideoViewProfileInStreamDefaultProfile will include all supporting elements with auto volume control. (Supporting MACRO: CEVideoViewProfileSpeaker, CEVideoViewProfileCountDown, CEVideoViewProfileSilentStart, CEVideoViewProfileAdIcon, CEVideoViewProfileSkipButton, CEVideoViewProfileAdCount)
(Deprecated)initWithPlacement
Instantiates a new InStream ad.
Parameters
placement
A specific group of ad units denoted in NSString, on which an advertiser can choose to place their ads using placement targeting
adContainer
UIView that ad will be played on
videoViewProfile
CEVideoViewProfile to define elements to be shown on Video ad. CEVideoViewProfileInStreamDefaultProfile will include all supporting elements with auto volume control. (Supporting MACRO: CEVideoViewProfileSpeaker, CEVideoViewProfileCountDown, CEVideoViewProfileSilentStart, CEVideoViewProfileAdIcon, CEVideoViewProfileSkipButton, CEVideoViewProfileAdCount)
Public Methods
registerViewForDismiss
Register view as Skip button.
Parameters
view
UIView to be registered for skip event.
registerFriendlyObstruction
Please pass any views that overlap ad view so that viewability tracking can be completed.
Parameters
views
UIView NSArray storing all views overlapping InStream ad
startAutoRequestAD
Request in-stream ads automatically. It shall only be called after CEInStreamAd is intialized. Please call startAutoRequestAD
for only one time for each CEInStreamAd instance.
contentComplete
Notification of the end of video content. It is critical to ensure Post-roll ad being served. If it is called in the middle of video content and there is ad to be served, post-roll ad will be served.
play
Play InStream ad.
stop
Stop InStream ad. Once certain InStream video ad is stopped, it cannot resume playing.
destroy
Release InStream ad. InStream ad shall at least be released along with the life cycle of video content.
getCuePoints
Return an array of cue points in NSNumber representing milli-second. Return nil
if total duration of content video is not available.
Returns
NSArray<NSNumber *>*
NSNumber array with all cue points in NSNumber representing milli-second
getCurrentADNum
Return the index(Start from 1) of InStream ad that is playing out of the number of ad should be served in current ad break. It should be called during ad break, otherwise it will return kCECurrentADNumInvalid
.
Returns
int
The index of InStream ad that is playing in current ad break
getTotalADNum
Return the total number of InStream ad that is expected to be played within current ad break. If it is not called in ad break or it is called in ad break but the total number of ad is not predictable, kCEToTalADNumInvalid
will be returned.
Returns
int
Total number of InStream ad that is expected to be played in current ad break
getADBreakRemainTime
Return the time left for current ad break. If it is not called in ad break or it is called in ad break but the remaining time of ad break cannot be calculated, getADBreakRemainTime
will be returned.
Returns
CEMilliSec
The time left for current ad break
getADRemainTime
Return the time left for current playing InStream ad. It should be called during ad break, otherwise it will return kCEADRemainTimeInvalid
.
Returns
CEMilliSec
The time left for current playing InStream ad
Public Properties
customEventExtra
Extra info that is passed in third-party custom event when InStream Ad is loaded.
Last updated