0

我创建了一个在按钮单击时播放电影的应用程序。我的应用程序正在运行,没有任何警告或错误。但是我看不到电影不知道为什么?我添加了媒体播放器框架并在 viewController.h 中导入了#import 我的按钮操作代码如下... -(IBAction)playMyMovie:(id)sender{

NSBundle *bundle =[NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"jumps" ofType:@"mov"];
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *theMovie =[[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.scalingMode = MPMovieScalingModeAspectFill;
[theMovie play];

}

请告诉我我错过了什么..

4

3 回答 3

2

在 iPhone 模拟器中,您无法正常播放电影。

在 iPhone(真实仪器)上测试应用程序。

它会正常工作。

于 2010-03-31T10:39:11.370 回答
0

尝试在 [theMovie play] 之前添加此行

[self.view addSubview:theMovie.view];

并且记得设置FullScreen:

[self.theMovie setFullscreen:YES];

如果您不想全屏但想嵌入到视图中,您可以忽略“setFullscreen”,但为 MPMoviePlayerController 视图设置框架:

[self.theMovie.view setFrame:CGRectMake("add in the size you want here")];
于 2011-04-15T02:31:37.170 回答
0

您正在创建一个 MPMoviePlayerController。它有一个view属性——那就是它的视图。将该视图放入您的界面是您的工作。如果你不这样做,你将什么都看不到。

于 2011-01-11T17:48:53.237 回答