完成播放时iOS 6,Xcode 4.5视频无法退出 [英] iOS 6, Xcode 4.5 video not exiting when done playing
本文介绍了完成播放时iOS 6,Xcode 4.5视频无法退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用此代码在iOS 6上播放视频:
I am using this code to play a video on iOS 6:
-(void)GrommeVideo4
{
NSURL *url5 = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"Flickers" ofType:@"mp4"]];
grommePlayer4 = [[MPMoviePlayerController alloc]
initWithContentURL:url5];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerWillExitFullscreen:)
name:MPMoviePlayerWillExitFullscreenNotification
object:nil];
grommePlayer4.controlStyle = MPMovieControlStyleDefault;
grommePlayer4.shouldAutoplay = YES;
[self.view addSubview:grommePlayer4.view];
[grommePlayer4 setFullscreen:YES animated:YES];
}
-(void) moviePlayBackDidFinish:(NSNotification *)aNotification{
[grommePlayer4.view removeFromSuperview];
grommePlayer4 = nil;
}
- (void)moviePlayerWillExitFullscreen:(NSNotification*) aNotification {
[grommePlayer4 stop];
[grommePlayer4.view removeFromSuperview];
grommePlayer4 = nil;
}
我可以随时按完成退出视频,它工作正常,但当我观看视频到最后,它只显示一个黑屏。关于为什么会发生这种情况的任何想法?
And I can press "Done" to exit the video at any time, and it works fine, but when I watch the video through to the end, it just displays a black screen. Any ideas as to why this could occur?
推荐答案
试试这个,希望它有所帮助
try this, hope it helps
-(void)GrommeVideo4
{
NSURL *url5 = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"Flickers" ofType:@"mp4"]];
grommePlayer4 = [[MPMoviePlayerController alloc]
initWithContentURL:url5];
grommePlayer4.controlStyle = MPMovieControlStyleDefault;
grommePlayer4.shouldAutoplay = YES;
[self.view addSubview:grommePlayer4.view];
[grommePlayer4 setFullscreen:YES animated:YES];
}
-(void) moviePlayBackDidFinish:(NSNotification *)aNotification{
[grommePlayer4.view removeFromSuperview];
grommePlayer4 = nil;
}
- (void)moviePlayerWillExitFullscreen:(NSNotification*) aNotification {
[grommePlayer4 stop];
[grommePlayer4.view removeFromSuperview];
grommePlayer4 = nil;
}
这篇关于完成播放时iOS 6,Xcode 4.5视频无法退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文