MPMoviePlayerController : orientation problem

隐身守侯 提交于 2019-12-21 23:15:24

问题


finally I have to post my problem here. Yes it could be duplicate question here as I have referred many answers regarding to this question.But I could not find any fix. (Also didn't find any question regarding to tab-bar app specific so...) And I don't want to use MPMoviePlayerViewController

I have tab-bar application. In last tab's VC there is a button. On click event I want to start movie player. For that I am using MPMoviePlayerController. Its all fine when orientation is Portrait . But regarding to changes, now I have to play it in landscape mode only.

here is my code :

-(void)playMovie
{
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
    [self.scrollView addSubview:moviePlayer.view];

    [moviePlayer play];
    [moviePlayer setFullscreen:TRUE];
}
-(void)btnPlayHandler:(id)sender
{   
    NSLog(@"btnPlayHandler");

    NSURL * videoUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[dictResponse valueForKey:@"VideoPath"]]];
    moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:videoUrl];
    //[moviePlayer.view setFrame:CGRectMake(20, 40, 280, 222)]; 
    moviePlayer.fullscreen = YES ;
    moviePlayer.shouldAutoplay = NO ;

    [self performSelector:@selector(playMovie) withObject:nil afterDelay:1];    
}

- (void) movieWillExit:(NSNotification *)notification
{
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
}

- (void) movieExit:(NSNotification *)notification
{
    [moviePlayer stop];
    [moviePlayer.view removeFromSuperview];
    moviePlayer = nil ;

    [btnPlay setHidden:FALSE];
}

- (void)moviePreLoad:(NSNotification *)notification  
{
    NSLog(@"moviePreLoad");
}

- (void)moviePlaybackComplete:(NSNotification *)notification  
{  
    NSLog(@"moviePlaybackComplete");
    [btnPlay setHidden:FALSE];
} 

Only device's orientation is changed not player's view ! How to accomplish this ??? Is it because the tab-bar application ?


回答1:


You are making the window landscape, but as you have set the MPMoviePlayer view in scrollview, it is not rotating. try to rotate the scrollview according to your orientation. See this link http://blog.sallarp.com/shouldautorotatetointerfaceorientation/. Hopefully it will solve your problem.



来源:https://stackoverflow.com/questions/7581435/mpmovieplayercontroller-orientation-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!