实施前贴片视频iAd [英] Implementing pre-roll video iAds

查看:116
本文介绍了实施前贴片视频iAd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

2014年10月,Apple宣布推出视频作为iAd的新广告格式

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?

推荐答案

检查我的示例,了解iAd预卷视频的工作实现广告:

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];
    }];
}

这篇关于实施前贴片视频iAd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆