我对MPMoviePlayerController有问题[iPhone SDK] [英] i have a problem with MPMoviePlayerController [iPhone SDK]
本文介绍了我对MPMoviePlayerController有问题[iPhone SDK]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个带有电影简介的应用,就像gameloft游戏一样.因此,当应用程序吃完午餐时,电影播放正常,但是在移动之前播放..我的FirstViewController xib文件先显示,然后电影开始播放!为什么 ?这是我的代码:
i want create an app with movie intro just like gameloft games . so when application has lunched , movie plays fine but before the move plays .. my FirstViewController xib file show first then movie start to play ! why ? here is my code :
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"movie" ofType:@"m4v"];
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *IntroMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
IntroMovie.movieControlMode = MPMovieControlModeHidden;
[IntroMovie play];
}
推荐答案
另一种方法是添加一个不同的视图(例如,简单的黑色背景),然后在视频播放完毕后替换它:
An alternative is to add a different view (e.g. simple black background) and then replace it when the video has finished playing:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"Hafez-2" ofType:@"mov"];
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *IntroMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[IntroMovie setOrientation:UIDeviceOrientationPortrait animated:NO];
[IntroMovie play];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
// Create an initial pure black view
UIView* blackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
blackView.backgroundColor = [UIColor blackColor];
[window addSubview:blackView]; // sends [blackView retain]
[blackView release];
[window makeKeyAndVisible];
}
- (void) moviePlaybackDidFinish:(NSNotification*)notification
{
UIView* blackView = [[window subviews] objectAtIndex:0];
[blackView removeFromSuperview]; // sends [blackView release]
[window addSubview:viewController.view];
}
让我知道您是否需要从示例中修改源代码,我可以将其发布到某个地方
Let me know if you need modified source from your example and I can post it somewhere
这篇关于我对MPMoviePlayerController有问题[iPhone SDK]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文