lundi 3 août 2015

implement iAd video with MPMoviePlayerController with playPrerollAdWithCompletionHandler method

Well, I want to show a video ad just before starting a video in MPMoviePlayer

This is what I am doing:-

moviePlayer = [MPMoviePlayerController new];

moviePlayer.contentURL = [NSURL URLWithString:@"http://xyz/xyz.m3u8"];

[moviePlayer playPrerollAdWithCompletionHandler:^(NSError *error) {
        // Check if error is non-nil during development
        [moviePlayer play];
    }];
moviePlayer.view.frame=CGRectMake(0, 20, 300, self.view.frame.size.width);

And in Appdelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    [MPMoviePlayerController preparePrerollAds];
    return YES;
}


[self.view addSubview:moviePlayer.view];
[self.view layoutIfNeeded];

But what more should I do to show an ad video or how to configure the iAD to let the app understand which specific video to play as ad.

Currently the app is just playing this url "http://xyz/xyz.m3u8" video but not showing any ad.

Aucun commentaire:

Enregistrer un commentaire