Skip to main content

Scheduled Video Ads

Implementing View Controller

In the view controller that will present the ad view as subview,

  • add these properties

    GFPVideoAdScheduleManager *scheduleManager

    IBOutlet UIView *videoView

    AVPlayer *contentPlayer

  • and implement this delegate protocol

    GFPVideoAdScheduleManagerDelegate

// MyViewController.h

@import GFPSDK;

@interface MyViewController : UIViewController <GFPVideoAdScheduleManagerDelegate>

@property (nonatomic) GFPVideoAdScheduleManager *scheduleManager;

@property (nonatomic) IBOutlet UIView *videoView;
@property (nonatomic) AVPlayer *contentPlayer;

@end

GFPVideoAdScheduleManager

Initialize GFPVideoAdScheduleManager in your view controller, say, in viewDidLoad: and request an ad.

  • Provide GFPVideoAdScheduleManager with video ad Schedule ID (essential) as registered on GFP dashboard, an AVPlayer instance, UIView to enclose video view, and GFPAdScheduleParam (optional) for better ad performance.

  • Set GFPVideoAdScheduleManagerDelegate (required) to GFPVideoAdScheduleManager

danger

GFPVideoAdScheduleManager must be manually deallocated by calling destroy: method.

- (void)viewDidLoad {
[super viewDidLoad];

GFPAdParam *adParam = [[GFPAdParam alloc]init];
adParam.yearOfBirth = 1990;
adParam.gender = GFPAdParamGenderTypeMale;
...

GFPVideoPlacementType type = GFPVideoPlacementTypePre | GFPVideoPlacementTypeMid | GFPVideoPlacementTypePost;
GFPAdScheduleParam *param = [[GFPAdScheduleParam alloc] initWithPlacementPolicy: type duration: CMTimeGetSeconds(Content duration) param: adParam];
param.noticeDurationSec = 5.0;
...

self.scheduleManager = [[GFPVideoAdScheduleManager alloc] initWithAdScheduleID: @"YOUR_SCHEDULE_ID"
contentPlayer: contentPlayer
videoView: videoView
scheduleParam: param];

self.scheduleManager.renderingSetting = [GFPVideoAdRenderingSetting alloc] init];

self.scheduleManager.delegate = self;
self.scheduleManager.qoeDelegate = self;

[self.scheduleManager loadSchedule];
}

Additional Configurations

Preliminary Ad Notice Duration

Video ad notice label refers to text label such as "Plays Ad in 5 Seconds", in advance of start playing ad video.

Set duration by GFPAdScheduleParam.noticeDurationSec

See its delegate method

scheduleParam.noticeDurationSec = 5.0;

GFPVideoAdScheduleManagerDelegate

Schedule Events

On Schedule Request Success

- (void)scheduleManager:(GFPVideoAdScheduleManager *)aScheduleAdManager didLoadedSchedule:(NSArray <GFPVideoAdBreak *> * _Nullable)aAdBreak {
...
}

On Schedule Request Failure

- (void)scheduleManager:(GFPVideoAdScheduleManager *)aScheduleAdManager didFailScheduleWithError:(GFPError *)aError {
...
}

On Schedule Complete

- (void)scheduleManagerDidCompleted:(GFPVideoAdScheduleManager *)aScheduleAdManager {
...
}

Video Playback Events

On Resuming Content

Called when the player resumes, in other words, continues to play content video in case of ad schedule failure or ad video fails to play

- (void)scheduleManagerContentResumeRequest:(GFPVideoAdScheduleManager *)aScheduleAdManager {
...
}

On Pausing Content

Called when the player pauses content to play ad video.

- (void)scheduleManagerContentPauseRequest:(GFPVideoAdScheduleManager *)aScheduleAdManager {
...
}

Video Ad Events

See more information in GFPVideoAdScheduleManagerDelegate.h

On Ad Failure

Ad failure includes ad load and ad video playback failure.

- (void)scheduleManager:(GFPVideoAdScheduleManager *)aScheduleAdManager didFailWithResult:(GFPVideoAdBreakResult *)aResult {
...
}

On Ad Loaded

- (void)scheduleManager:(GFPVideoAdScheduleManager *)aScheduleAdManager didLoadAd:(GFPVideoAdBreakResult *)aResult {
...
}

On Ad Video Started

- (void)scheduleManager:(GFPVideoAdScheduleManager *)aScheduleAdManager didStartAd:(GFPVideoAdBreakResult *)aResult {
...
}

On Ad Video Ready

- (void)scheduleManager:(GFPVideoAdScheduleManager *)aScheduleAdManager didStartReadyAd:(GFPVideoAdBreakResult *)aResult {
/* 1. Manually hide preliminary ad notice label */
/* 2. Manually stop content video player. */
...
[self.scheduleAdManager startWith: NO or YES]; /* 3. Start ad video */
}

On Video Ad Playback Ended

- (void)scheduleManager:(GFPVideoAdScheduleManager *)aScheduleAdManager didCompleteAd:(GFPVideoAdBreakResult *)aResult {
...
}

On Show Preliminary Ad Notice Label

GFPAdScheduleParam.noticeDurationSec must be set to call this delegate method.

SDK only notifies the time to show the notice label through this method. It is app's will to manually render the notice label view.

- (void)scheduleManager:(GFPVideoAdScheduleManager *)aScheduleAdManager showAdNotice:(NSInteger)aDuration {
/* Show to notice label */
...
}

On Clicked

- (void)scheduleManager:(GFPVideoAdScheduleManager *)aScheduleAdManager wasClicked:(GFPVideoAdBreakResult *)aResult {
...
}

AVPlayer Log Event

It is called only if video player is configured as AVPlayer.

- (void)scheduleManager:(GFPVideoAdScheduleManager *)aScheduleAdManager
didReceiveAccessLogEvents:(NSArray<AVPlayerItemAccessLogEvent *> *)accessLogEvents {
...
}

Remind(NonLinear) Ad Events

See more information in GFPNonLinearDelegate.h

On Remind Ad Hidden

It is called when the video duration is completed, device being rotated or close button being clicked.

- (void)nonLinearDidHide:(GFPRemindType)type {
...
}

On Remind Ad Clicked

- (void)nonLinearWasClicked:(GFPRemindType)type {
...
}

On Remind Ad View Impression

- (void)nonLinearOnActiveImpression:(GFPRemindType)type {
...
}

Video Ad UI Configuration

Set displayMode to change ad video player's UI to be taylored according to video being played in a picture in picture(PiP) or a normal context.

  • Normal Mode

샘플 이미지 샘플 이미지

self.scheduleManager.displayMode = [GFPVideoDisplayMode normal];
  • PiP Mode

샘플 이미지 샘플 이미지

self.scheduleManager.displayMode = [GFPVideoDisplayMode pip];

PiP Callbacks

Set a GFPVideoAdScheduleManagerPIPDelegate to the GFPVideoAdScheduleManager

On Close Button Tapped

- (void)scheduleManager:(GFPVideoAdScheduleManager *)aScheduleAdManager didTappedCloseBtnInPIP:(GFPVideoAdBreakResult *)aResult {

}

On Return Button Tapped

- (void)scheduleManager:(GFPVideoAdScheduleManager *)aScheduleAdManager didTappedReturnBtnInPIP:(GFPVideoAdBreakResult *)aResult {

}

ControlView Callbacks

Set a GFPVideoAdScheduleManagerDelegate to the GFPVideoAdScheduleManager

On ControlView Will Show

The duration refers to animation's, when showing the control buttons.

- (void)scheduleManager:(GFPVideoAdScheduleManager *)aScheduleAdManager playControlWillShow:(NSTimeInterval)duration {

}

On ControlView Will Hide

The duration refers to animation's, when hiding the control buttons.

- (void)scheduleManager:(GFPVideoAdScheduleManager *)aScheduleAdManager playControlWillHide:(NSTimeInterval)duration {

}

Auxiliary

Controlling Player UI

See more information in GFPVideoAdScheduleManager.h.

Showing Overlays (playback slider, pause button, resume button, election notice label and end text)

- (void)showOverlayView;

Hiding Overlays

- (void)hideOverlayView;

Showing RemindAd(Banner, Text)

Remind Ad is a pop-up small image or text view showing after video ad ended.

- (void)showRemindAd;

Hiding RemindAd(Banner, Text)

- (void)hideRemindAd;

Implementing Remind Ad for SMR

Customize the Remind Ad by configuring GFPTextAdViewAttribute.

See more information in Yobi internal document: Scheduled Ad Guide

GFPTextAdViewAttribute *attribute = [[GFPTextAdViewAttribute alloc] initWithContainer: aContainer];
attribute.backgroundColor = [UIColor yellowColor];
attribute.textColor = [UIColor redColor];
attribute.verticalBarColor = [UIColor cyanColor];
attribute.closeIcon = [UIImage imageNamed: @"close"];
attribute.moreIcon = [UIImage imageNamed: @"more"];

Configuring NonLinear Outer Container

Use GFPVideoAdScheduleManager.replaceTextAdViewAttribute: to configure GFPTextAdViewAttribute.

- (void)replaceTextAdViewAttribute:(GFPTextAdViewAttribute *)textAdViewAttribute {

}