安装Xcode 4.5,MPMoviePlayerController不再工作

时间:2012-10-01 04:03:51

标签: ios xcode ios6

我非常高兴看到“升级”到Xcode 4.5时,现在我应用中的所有视频都没有播放。

一般来说,我会这样做:

self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[self getBundleClip:@"theVideo"]];
self.moviePlayer.controlStyle = MPMovieControlStyleNone;
self.moviePlayer.shouldAutoplay = YES;
self.moviePlayer.repeatMode = MPMovieRepeatModeOne;
self.moviePlayer.view.frame = self.container.frame;
self.moviePlayer.view.userInteractionEnabled = NO;
[self.container addSubview:self.moviePlayer.view];

- (NSURL*)getBundleClip:(NSString*)clip
{
    NSBundle *bundle = [NSBundle mainBundle];
    NSString *moviePath = [bundle pathForResource:clip ofType:@"mp4"];
    return [NSURL fileURLWithPath:moviePath];
}

同样,在我将Xcode更新为4.5之前,一切都很完美。其他人有这个问题吗?

我也得到了这个输出:

[MPAVController] Autoplay: Disabling autoplay for pause
[MPAVController] Autoplay: Disabling autoplay

2 个答案:

答案 0 :(得分:4)

我想你在函数中定义它?

如果使用ARC,则必须保留MPMoviePlayerController

将其添加到界面文件中!

@property(nonatomic, strong) MPMoviePlayerController *moviePlayer;

答案 1 :(得分:0)

我不确定为什么它没有专门播放,但看起来行为会有所不同,具体取决于您构建的iOS SDK版本。查看MPMoviePlayerController documentation

特别是,您可能想尝试在电影播放器​​上调用prepareToPlay方法。