我看不到 iPhone 模拟器中正在播放的电影

发布于 2024-08-16 01:37:02 字数 562 浏览 6 评论 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];

}

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

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜雨飘雪 2024-08-23 01:37:02

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

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

它会工作得很好。

in iPhone simulator you could not play movie properly.

test the applcation on iPhone (Real instrument).

It will work fine.

满身野味 2024-08-23 01:37:02

您正在创建一个 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.

苦行僧 2024-08-23 01:37:02

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

[self.view addSubview:theMovie.view];

,并记住 setFullScreen:

[self.theMovie setFullscreen:YES];

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

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

try add this line before the [theMovie play]

[self.view addSubview:theMovie.view];

and also remember to setFullScreen:

[self.theMovie setFullscreen:YES];

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:

[self.theMovie.view setFrame:CGRectMake("add in the size you want here")];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文