我看不到 iPhone 模拟器中正在播放的电影
我创建了一个在单击按钮时播放电影的应用程序。我的应用程序正在运行,没有任何警告或错误。但我看不到这部电影,不知道为什么? 我添加了媒体播放器框架,并在 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];
}
请告诉我我错过了什么..
i have created a application that plays movie on button click..my application is running without any warning or error. But i am not able to see the movie don't know why?
I have added the Media player framework and also imported the #import in viewController.h
my button action code is as follow...
-(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];
}
Please tell me what i am missing..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 iPhone 模拟器中,您无法正常播放电影。
在 iPhone(真实仪器)上测试该应用程序。
它会工作得很好。
in iPhone simulator you could not play movie properly.
test the applcation on iPhone (Real instrument).
It will work fine.
您正在创建一个 MPMoviePlayerController。它有一个
view
属性 - 这就是它的视图。您的工作就是将该视图放入您的界面中。如果不这样做,您将看不到任何东西。You are creating a MPMoviePlayerController. It has a
view
property - that is its view. It is your job to put that view into your interface. If you don't, you won't see anything.尝试在 [theMovie play] 之前添加此行
,并记住 setFullScreen:
如果您不想全屏但想嵌入到视图中,您可以忽略“setFullscreen”,但设置 MPMoviePlayerController 视图的框架:
try add this line before the [theMovie play]
and also remember to setFullScreen:
if you dont want fullscreen but want to embed into the view, you can ignore the "setFullscreen", but set the frame for the MPMoviePlayerController view: