iPhone - 将视频显示为启动画面

发布于 2024-10-09 19:13:24 字数 981 浏览 2 评论 0原文

我需要在我的 iPhone 应用程序中将视频显示为闪屏 我正在使用以下代码:

-(void)setupMovie{
NSString* moviePath = [[NSBundle mainBundle] pathForResource:@"iphone" ofType:@"mp4"];
NSURL* movieURL = [NSURL fileURLWithPath:moviePath];

playerCtrl =  [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
playerCtrl.scalingMode = MPMovieScalingModeFill;
playerCtrl.controlStyle = MPMovieControlStyleNone;
playerCtrl.view.frame = CGRectMake(0, 0, 480, 320);

[[NSNotificationCenter defaultCenter] addObserver:self 
                     selector:@selector(moviePlayBackDidFinish:) 
                              name:MPMoviePlayerPlaybackDidFinishNotification object:nil];

[playerCtrl.view setCenter:CGPointMake(240, 160)];
[playerCtrl.view setFrame:CGRectMake(0, 0, 480, 320)];
[playerCtrl.view setTransform:CGAffineTransformMakeRotation(-M_PI/2)];
[self.window addSubview:playerCtrl.view];
[playerCtrl play];}

但播放器视图并非从 x=0,y=0 位置开始。这是什么原因以及如何解决。 它的起始 x=100,y=100(大约)。

I've the requirement to show video as splash screen in my iphone app
I'm using following code:

-(void)setupMovie{
NSString* moviePath = [[NSBundle mainBundle] pathForResource:@"iphone" ofType:@"mp4"];
NSURL* movieURL = [NSURL fileURLWithPath:moviePath];

playerCtrl =  [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
playerCtrl.scalingMode = MPMovieScalingModeFill;
playerCtrl.controlStyle = MPMovieControlStyleNone;
playerCtrl.view.frame = CGRectMake(0, 0, 480, 320);

[[NSNotificationCenter defaultCenter] addObserver:self 
                     selector:@selector(moviePlayBackDidFinish:) 
                              name:MPMoviePlayerPlaybackDidFinishNotification object:nil];

[playerCtrl.view setCenter:CGPointMake(240, 160)];
[playerCtrl.view setFrame:CGRectMake(0, 0, 480, 320)];
[playerCtrl.view setTransform:CGAffineTransformMakeRotation(-M_PI/2)];
[self.window addSubview:playerCtrl.view];
[playerCtrl play];}

But the player view is not starting at x=0,y=0 location. What's the reason and how to fix it.
Its starting x=100,y=100 (approx).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

清引 2024-10-16 19:13:24

您正在设置影响位置的信息三次

playerCtrl.view.frame = CGRectMake(0, 0, 480, 320);
[playerCtrl.view setCenter:CGPointMake(240, 160)];
[playerCtrl.view setFrame:CGRectMake(0, 0, 480, 320)];

,因此请依次尝试

you are setting the information which affects the position three times

playerCtrl.view.frame = CGRectMake(0, 0, 480, 320);
[playerCtrl.view setCenter:CGPointMake(240, 160)];
[playerCtrl.view setFrame:CGRectMake(0, 0, 480, 320)];

so try one after another

活雷疯 2024-10-16 19:13:24

旋转后设置框架:

playerCtrl.view.frame = CGRectMake(0, 0, 320, 480);

Set frame after rotation:

playerCtrl.view.frame = CGRectMake(0, 0, 320, 480);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文