我有一个 MPMoviePlayerController 播放嵌入在视图中的视频。这在 iOS5/5.1 等上运行良好......但自从升级到 iOS6 后,它已经停止工作,现在视图只是黑色。有没有人有任何想法或类似问题?
谢谢
我有一个 MPMoviePlayerController 播放嵌入在视图中的视频。这在 iOS5/5.1 等上运行良好......但自从升级到 iOS6 后,它已经停止工作,现在视图只是黑色。有没有人有任何想法或类似问题?
谢谢
试试这个......
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];
我是访问同样的问题,最后发现关键行“[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];
实际上,MPMediaTypeMusicVideo 定义为 MPMediaType,定义如下: MPMediaTypeMusicVideo = 1 << 11, (2048)
它是无证的东西吗?