我能够在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文件?
答案 0 :(得分:1)
我可能和你有同样的问题。如果您查看日志,是否会收到以下错误:
_itemFailedToPlayToEnd: {
kind = 1;
new = 2;
old = 0;
}
我唯一的另一个想法是使用AVPlayer等新类甚至是第三方类来播放我的媒体。我在代码和代码中都没有看到任何不正确的设置。它与iOS 7有关。