开发者

Flipping a Video Horizontally in Xcode

开发者 https://www.devze.com 2023-02-23 14:30 出处:网络
I have a video such that when I play it in full view and flip the simulator horizontally the video would not flip. How can I make the video flip according to the iPhone\'s accelerometer?

I have a video such that when I play it in full view and flip the simulator horizontally the video would not flip. How can I make the video flip according to the iPhone's accelerometer?

Here is the co开发者_C百科de for the video if it helps:

- (void)viewDidAppear:(BOOL)animated {

    NSBundle *bundle=[NSBundle mainBundle];
    NSString *moviePath = [bundle pathForResource:@"MainPageMovie" ofType:@"mp4"];
    NSURL *movieURL=[[NSURL fileURLWithPath:moviePath] retain];
    MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
    theMovie.scalingMode = MPMovieScalingModeAspectFill;
    theMovie.view.frame = CGRectMake(115.0, 156.0, 200.0, 150.0);
    [self.view addSubview:theMovie.view];
    [theMovie play];

    [super viewDidLoad];
    self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];
}


Your MPMoviePlayerController view is added as a subview to another view controller's view. In that parent view controller, have you overridden shouldAutorotateToInterfaceOrientation method? If you are just looking for landscape (horizontal) rotation, you can have your code as below:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Overriden to allow any orientation.
    return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}


In order to rotate specific subviews of the larger view controller view, (which in your situation would be the case with only rotating the video), you'd have to do CGAffineTransforms. This would allow you to resize a view, rotate it, etc. AFAIK, this is probably the best route to go for rotating a single view.

However, you may want to research more into MPMoviePlayerViewController. Take a look at this post, it seems to address your problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消