加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ios – 实现前贴片视频iAd

发布时间:2020-12-15 01:48:36 所属栏目:百科 来源:网络整理
导读:2014年10月,Apple宣布推出视频作为iAd的新广告格式 https://developer.apple.com/iad/resources/Implementing-iAd-in-Your-iOS-Apps.PDF 但是,没有关于实施它们的官方文件.这种格式是否可用,如果可以,它们如何实施? 解决方法 查看我的示例,了解iAd预卷视频
2014年10月,Apple宣布推出视频作为iAd的新广告格式

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

但是,没有关于实施它们的官方文件.这种格式是否可用,如果可以,它们如何实施?

解决方法

查看我的示例,了解iAd预卷视频广告的实施情况:

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读