gpt4 book ai didi

ios - 如何使用 IMA SDK 快速播放带 MPMoviePlayerController 的前置视频广告

转载 作者:搜寻专家 更新时间:2023-11-01 05:41:51 24 4
gpt4 key购买 nike

我正在使用 swift 语言开发 iOS 应用程序。我需要在我的应用程序中实现谷歌前置视频广告,我正在实现使用 MPMoviePlayerController 播放视频。因此我可以使用 MPMoviePlayerController 播放 DFP 前置视频广告。如何使用 MPMoviePlayerController 快速实现 IMA SDK。请提供一些示例以及使用 Out IMA SDK 播放 DFP 前置广告视频的任何其他选项

谢谢

最佳答案

NSURL *fileURL = [NSURL URLWithString:urlplay];
moviePlayerController=[[MPMoviePlayerController alloc]initWithContentURL:fileURL];

[NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(updatePlaybackProgressFromTimer:)
userInfo:nil
repeats:YES];

UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
tap.delegate = self;
tap.numberOfTapsRequired = 1;
[moviePlayerController.view addGestureRecognizer:tap];
moviePlayerController.movieSourceType = MPMovieSourceTypeStreaming;

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(Exit:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playstart:) name:MPMediaPlaybackIsPreparedToPlayDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(Statechange:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(LoadFinish:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];

[moviePlayerController setFullscreen:YES animated:YES];
moviePlayerController.view.frame = CGRectMake(0,568, [AppDelegate sharedInstance].widht, [AppDelegate sharedInstance].height);
[self.navigationController setNavigationBarHidden:YES];
[UIView animateWithDuration:0.7
delay:0.5
options: UIViewAnimationCurveEaseOut
animations:^{
[moviePlayerController.view setFrame:CGRectMake(0,0,[AppDelegate sharedInstance].widht, [AppDelegate sharedInstance].height)];
}
completion:^(BOOL finished)
{
}];

moviePlayerController.controlStyle=MPMovieControlStyleFullscreen;
moviePlayerController.backgroundView.hidden = YES;
[self.view addSubview:moviePlayerController.view];

[moviePlayerController play];

关于ios - 如何使用 IMA SDK 快速播放带 MPMoviePlayerController 的前置视频广告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28607116/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com