0

在我的 ViewController 中,我放置MPMoviePlayerController播放视频。它工作正常。它也可以在全屏模式下播放。现在,我需要在横向右侧横向左侧播放这部电影。我如何实现这一目标?而且,重要的一点是我的应用只支持纵向模式。我只想在两个方向上显示这个电影播放器​​。我怎么做?任何想法都值得!

这是我的代码 -

-(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:)])    {
    }
}
4

1 回答 1

0

我在这里用代码回答了这个问题:将方向更改回纵向

You have an app that supports all orientations, a main view controller that only supports portrait, and a subclassed MPMoviePlayerController that supports all orientations (or all, but upside down, or landscape only, or whatever you want...).

于 2013-03-30T08:19:31.520 回答