0

我能够在 ios 6.1.3 及更低版本中使用以下编码播放 .mov 文件,但在 iOS7 中它会自动关闭。

MPMoviePlayerViewController *mp1 = [[ MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
if (mp1)
{
    self.moviePlayer= mp1;
    [mp1 release];
    self.moviePlayer.view.userInteractionEnabled=YES;
    self.moviePlayer.moviePlayer.repeatMode = MPMovieRepeatModeOne;

    self.moviePlayer.view.frame = CGRectMake(0, 0, 320, 460);
    [self.moviePlayer.moviePlayer setScalingMode:MPMovieScalingModeAspectFit];

    self.moviePlayer.moviePlayer.controlStyle = MPMovieControlStyleDefault;

    //Register for the playback finished notification.
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(myMovieFinishedCallback:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:self.moviePlayer.moviePlayer];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerDidExitFullscreenNotification object:self.moviePlayer.moviePlayer];

    //setup device rotation notification observer
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(didRotate:)
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];

    [self.masterVC presentMoviePlayerViewControllerAnimated:moviePlayer];
    [self.moviePlayer.moviePlayer prepareToPlay];
    [self.moviePlayer.moviePlayer play];
    [self.moviePlayer.moviePlayer setFullscreen:TRUE];

}

使用上面的编码,我可以在 iOS7 中播放 .mp4 文件。苹果是否限制 mov 文件?

4

1 回答 1

1

我可能和你有同样的问题。如果您查看日志,是否会收到以下错误:

_itemFailedToPlayToEnd: { 
    kind = 1; 
    new = 2; 
    old = 0;
}

我唯一的另一个想法是使用诸如 AVPlayer 之类的新类,甚至是第三方类来播放我的媒体。我在您的代码和我的代码中都没有看到任何不正确的设置。它与 iOS 7 相关。

于 2013-09-30T14:46:40.193 回答