开发者

MPMoviePlayerController : orientation problem

开发者 https://www.devze.com 2023-04-08 00:49 出处:网络
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

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:@开发者_JAVA百科"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 ?


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.

0

精彩评论

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

关注公众号