2009-12-17 131 views
0

我已经创建了一个应用程序,播放电影按钮click..my应用程序正在运行没有任何警告或错误。但我无法看到电影不知道为什么? 我已经添加了媒体播放器框架,还进口了#进口在viewController.h 我按钮动作代码如下... - (IBAction为)playMyMovie:(ID)发送{我看不到在iphone模拟器中播放的电影

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]; 

}

请告诉我我缺少什么。

回答

2

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

测试iPhone上的应用程序(真实乐器)。

它会正常工作。

0

您正在创建一个MPMoviePlayerController。它有一个view财产 - 这是它的观点。将您的观点放入您的界面是您的职责。如果你不这样做,你什么都看不到。

0

尝试[theMovie播放]前加入这一行

[self.view addSubview:theMovie.view]; 

还记得setFullScreen:

[self.theMovie setFullscreen:YES]; 

如果你不想全屏,但要嵌入到视图中,可以忽略“setFullscreen”,但设置MPMoviePlayerController视图的帧:

[self.theMovie.view setFrame:CGRectMake("add in the size you want here")]; 
相关问题