How To Rotate An MPMoviePlayerController

前端 未结 3 1394
抹茶落季
抹茶落季 2020-12-15 02:01

I am building an iPhone app that plays videos on demand from a web service.

The videos play in an MPMoviePlayerController, and everything works fine on the iPhone de

相关标签:
3条回答
  • 2020-12-15 02:52

    i found this way only useful but it is timetaking to set the desired frame-

    theMovie=[[MPMoviePlayerController alloc] initWithContentURL:theURL]; 
    // Rotate the view for landscape playback   
    [[theMovie view] setBounds:CGRectMake(-230, 155, 480, 350)];
    [[theMovie view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)]; 
    
    0 讨论(0)
  • 2020-12-15 02:52

    Have a fix for the portrait in landscape iPad problem here too (see link), would be interested to know what you did to fix it if different.

    link to thread

    0 讨论(0)
  • 2020-12-15 02:54

    iPad apps are supposed to support all four interface orientations.

    EDIT: I haven't managed to find official docs to cite. It might be simply that iPad apps are supposed to be able to launch in all orientations, though you can force some bits to be landscape if it's "sensible". Whether Apple rejects your app or not is another issue, but I think they're unlikely to reject a video app that plays video in landscape.

    After some experimentation, the following seems to work:

    @interface MyMovieViewController : MPMoviePlayerViewController
    @end
    
    @implementation MyMovieViewController
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
    {
        return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
    }
    
    @end
    

    Then just instantiate MyMovieViewController instead of MPMoviePlayerViewController.

    EDIT 2: MPMoviePlayerViewController is not the same as MPMoviePlayerController; you use it to get the behaviour of the 2.0-3.1 MPMoviePlayerController. You need to add the view controller to the VC hierarchy, but it's pretty simple (and a lot easier than messing around with view transforms):

    MPMoviePlayerViewController * vc = [[MyMovieViewController alloc] initWithContentURL:aUrl];
    [self presentMoviePlayerViewControllerAnimated:vc];
    [vc.moviePlayer play];
    
    0 讨论(0)
提交回复
热议问题