【发布时间】:2010-10-21 21:59:19
【问题描述】:
我正在尝试播放介绍电影(如闪屏)。它曾经适用于 sdk 3.0,但现在我正在为 iPad 做这件事。它没有运行电影,而是在视图出现之前显示黑屏。 这是我的代码
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"intro" ofType:@"m4v" inDirectory:nil];
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:movieURL];
moviePlayer.fullscreen=YES;
moviePlayer.view.frame = CGRectMake(0, 0,1024,768);
[moviePlayer setShouldAutoplay:YES];
[moviePlayer setControlStyle:MPMovieControlStyleNone];
[moviePlayer setRepeatMode:MPMovieRepeatModeNone];
[moviePlayer prepareToPlay];
[moviePlayer play];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
return YES;
}
这是我的电影PlaybackDidFinish
- (void) moviePlaybackDidFinish:(NSNotification*)notification
{
MPMoviePlayerController *theMovie = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:theMovie];
theMovie.initialPlaybackTime = -1;
[theMovie pause];
[theMovie stop];
[theMovie release];
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}
我不知道我在这里缺少什么?
感谢您的帮助....
更新我刚刚发现它可以播放声音但没有视频....这很明显吗?请帮助
【问题讨论】:
标签: iphone ipad ios4 mpmovieplayercontroller