3

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).

Satyam
  • 15,493
  • 31
  • 131
  • 244

2 Answers2

0

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

0

Set frame after rotation:

playerCtrl.view.frame = CGRectMake(0, 0, 320, 480);
Sound Blaster
  • 4,778
  • 1
  • 24
  • 32