【发布时间】:2010-11-02 03:00:41
【问题描述】:
我是 xcode、界面生成器和 iphone 模拟器的新手。我正在尝试通过单击按钮在 xcode 中播放电影/视频(这非常简单)。我正在使用 xcode 3.2.4 和 iphone 模拟器 4.1。
当我启动 iPhone 模拟器并单击按钮启动视频时,音频播放,但视频被隐藏。就好像视频在标签栏后面(这是标签栏应用程序的一部分)。我不知道如何让视频在前面播放。
代码如下:
-(IBAction)launchVideo2:(id)sender{
NSString *movieFile;
MPMoviePlayerController *moviePlayer;
movieFile = [[NSBundle mainBundle]
pathForResource:@"IGDIs_Video_Picture_Naming_iPhone" ofType:@"mp4"];
moviePlayer = [[MPMoviePlayerController alloc]
initWithContentURL: [NSURL fileURLWithPath: movieFile]];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playMediaFinished:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
[moviePlayer play];
}
-(void)playMediaFinished:(NSNotification*)theNotification
{
MPMoviePlayerController *moviePlayer=[theNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
[moviePlayer release];
}
任何建议都会很棒!
【问题讨论】:
标签: iphone video uitabbarcontroller ios-simulator mpmovieplayercontroller