MPMoviePlayer在多个方向

时间:2013-03-30 07:36:02

标签: iphone ios mpmovieplayercontroller

在我的ViewController中,我正在放置MPMoviePlayerController来播放视频。它工作正常。它也能够以全屏模式播放。现在,我需要在 Landscape right Landscape left 中播放这部电影。我如何实现这一目标?而且,重要的注意事项是我的应用程序仅支持 Portrait 模式。我只想在两个方向上显示这个电影播放器​​。我怎么做?任何想法都明显!

这是我的代码 -

-(void)playMovie
{
    NSString *movieURL = ___;
    NSURL *url = [NSURL URLWithString:movieURL];
    player =  [[MPMoviePlayerController alloc]initWithContentURL:url];
    self._moviePlayer = player;

    [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:_moviePlayer];

    _moviePlayer.controlStyle = MPMovieControlStyleDefault;
    _moviePlayer.shouldAutoplay = YES;

    _moviePlayer.view.frame = CGRectMake(10, shortDesc.frame.origin.y+shortDesc.frame.size.height+10, 280,150);

    [_moviePlayer play];
}


- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
    player = [notification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:player];

    if ([player respondsToSelector:@selector(setFullscreen:animated:)])    {
    }
}

1 个答案:

答案 0 :(得分:0)

我在这里已经回答了这个问题,代码为:Change Orientation back to Portrait

您有支持所有方向的应用,仅支持肖像的主视图控制器子类 MPMoviePlayerController支持所有方向(或全部,但颠倒,或只有风景,或任何你想要的......)。