【发布时间】:2016-05-03 07:49:34
【问题描述】:
我正在使用 MPMoviePlayerController 播放一个小视频作为我的应用的介绍视频。我已经使用了以下代码,并且效果很好。但是视频一直在播放。结束并再次重新启动。即使我单击完成按钮,它也不会删除超级视图。我还希望我的状态栏可见,并且我保持半透明仍然没有结果。我在谷歌上搜索和堆栈溢出但仍然没有帮助。任何帮助都会非常显着。
我在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];
}
}
【问题讨论】:
标签: ios objective-c xcode mpmovieplayercontroller