gpt4 book ai didi

ios - MPMoviePlayerController 行为不正常

转载 作者:行者123 更新时间:2023-11-28 18:53:34 25 4
gpt4 key购买 nike

我正在使用 MPMoviePlayerController 播放一个小视频作为我的应用程序的介绍视频。我使用了以下代码,效果很好。但是视频继续播放。结束并重新开始。即使我点击完成按钮,它也不会删除 super View 。我也希望我的状态栏可见并且我保持半透明仍然没有结果。我在谷歌和堆栈溢出上搜索但仍然没有帮助。任何帮助将不胜感激。

我在 viewDidAppear 中调用了 [self playMovie] 方法

-(void)playMovie
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"avc_intro" ofType:@"mp4"]];
moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL:url];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
name:MPMoviePlayerWillExitFullscreenNotification
object:moviePlayer];

moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
}

- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
MPMoviePlayerController *videoplayer = [notification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:videoplayer];

if ([videoplayer
respondsToSelector:@selector(setFullscreen:animated:)])
{
[videoplayer.view removeFromSuperview];
}
}

最佳答案

更好用this.MPMoviePlayerController 已在 iOS 9 中正式弃用。

关于ios - MPMoviePlayerController 行为不正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36998527/

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