实施前置视频 iAd

2023-12-13

2014 年 10 月,苹果宣布将前贴片视频作为 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];
    }];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

实施前置视频 iAd 的相关文章

随机推荐