MPMoviePlayerController:方向问题 [英] MPMoviePlayerController : orientation problem

查看:63
本文介绍了MPMoviePlayerController:方向问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最后,我必须在这里发布我的问题.是的,这里可能是重复的问题,因为我已经提到了许多有关此问题的答案,但我找不到任何解决方法. (也没有找到有关特定于选项卡栏应用程序的问题,所以...)而且我也不想使用MPMoviePlayerViewController

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

我有标签栏应用程序.在最后一个标签的VC中有一个按钮.点击事件时,我想启动电影播放器​​.为此,我正在使用MPMoviePlayerController.当方向为 Portrait 时,一切都很好.但是关于更改,现在我只能在横向模式下播放它.

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.

这是我的代码:

-(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 ?

推荐答案

您正在制作窗口横向视图,但是由于在滚动视图中设置了MPMoviePlayer视图,因此该视图不会旋转.尝试根据您的方向旋转滚动视图. 请参阅此链接 http://blog.sallarp.com/shouldautorotatetointerfaceorientation/.希望它能解决您的问题.

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.

这篇关于MPMoviePlayerController:方向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆