Implementing pre-roll video iAds

允我心安 提交于 2019-11-29 23:46:08

问题


In October 2014 Apple announced pre-roll video as a new ad format for iAd

https://developer.apple.com/iad/resources/Implementing-iAd-in-Your-iOS-Apps.PDF

However, there is no official documentation on implementing them. Is this format available yet and if so how can they be implemented?


回答1:


Check my example for a working implementation of iAd's prerolled video ads:

#import "ViewController.h"
@import iAd;
@import MediaPlayer;

@interface ViewController () {
    MPMoviePlayerController *moviePlayer;
}

@end

@implementation ViewController

-(void)viewDidLoad {
    [super viewDidLoad];

    // Preload ad
    [MPMoviePlayerController preparePrerollAds];

    // Create our MPMoviePlayerController
    moviePlayer =[[MPMoviePlayerController alloc]init];
    [moviePlayer.view setFrame: self.view.bounds];
    [moviePlayer setFullscreen:YES animated:YES];
}

-(IBAction)playButton:(id)sender {
    // Add MPMoviePlayerController to our view
    [self.view addSubview:moviePlayer.view];

    // Path of movie you want to play
    NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"someVideo" ofType:@"MOV"];

    // Set the contents of our MPMoviePlayerController to our path
    [moviePlayer setContentURL:[NSURL fileURLWithPath:moviePath]];

    // Prepare our movie for playback
    [moviePlayer prepareToPlay];

    // Play our movie with a prerolled ad
    [moviePlayer playPrerollAdWithCompletionHandler:^(NSError *error) {
        if (error) {
            NSLog(@"%@",error);
        }
        [moviePlayer play];
    }];
}


来源:https://stackoverflow.com/questions/27018973/implementing-pre-roll-video-iads

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!