我有一个MPMoviePlayerController,它可以播放View中嵌入的视频。这在iOS5 / 5.1等上完美运行......但是自从升级到iOS6后,这已停止工作,现在视图只是黑色。有没有人有任何想法或类似问题?
由于
答案 0 :(得分:10)
试试这个......
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"ddd" ofType:@"mp4"];
NSURL *url = [NSURL fileURLWithPath:resourcePath];
MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
moviePlayer.view.frame = CGRectMake(0, 0, 500, 500);
moviePlayer.moviePlayer.shouldAutoplay=YES;
moviePlayer.moviePlayer.controlStyle = MPMediaTypeMusicVideo;
[moviePlayer.moviePlayer setFullscreen:YES animated:YES];
[self.view addSubview:moviePlayer.view];
[moviePlayer.moviePlayer play];
答案 1 :(得分:5)
我访问了同样的问题,最后发现关键行“[player prepareToPlay]”丢失了。在iOS5中它没有关系,但在iOS6中它会导致黑屏;
MPMoviePlayerController *player =
[[MPMoviePlayerController alloc] initWithContentURL: myURL];
[player prepareToPlay];
[player.view setFrame: myView.bounds]; // player's frame must match parent's
[myView addSubview: player.view];
// ...
[player play];
答案 2 :(得分:1)
实际上,MPMediaTypeMusicVideo被定义为MPMediaType,下面是定义: MPMediaTypeMusicVideo = 1<< 11,(2048)
这是无证件吗?