IPhone - display video as a screensaver

I have a requirement to show the video as a splash screen in my iphone application I use the 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’s performance does not start with the location x = 0, y = 0. What is the reason and how to fix it. Its beginning is x = 100, y = 100 (approximate).

+3
source share
2 answers

you set information that 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)];

try one by one

0
source

Install the frame after rotation:

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

Source: https://habr.com/ru/post/1783011/


All Articles