0

我在使用 MPMoviePlayerController 时遇到问题。它在 ios 5 中不起作用,只是显示一个黑屏。甚至没有抛出任何异常或任何错误。这是我的代码:

NSString *path = [[NSBundle mainBundle] pathForResource:@"cavity" ofType:@"mov"];
NSLog(@"%@",path);
_movieController = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:path]];
[_movieController prepareToPlay];
[_movieController setFullscreen:NO];
[_movieController.view setFrame:CGRectMake(10, 25, 287, 213)];
[_movieController setControlStyle:MPMovieControlStyleEmbedded];

[_movieView addSubview:_movieController.view];
[_movieController play];

_movieController 对象已在 .h 文件中声明,但仍未处于工作状态。

4

1 回答 1

0

尝试这个

 MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:url]];

[[mp moviePlayer] prepareToPlay];
[[mp moviePlayer] setUseApplicationAudioSession:NO];
[[mp moviePlayer] setShouldAutoplay:YES];
[[mp moviePlayer] setControlStyle:2];
[[mp moviePlayer] setRepeatMode:MPMovieRepeatModeOne];
[self presentMoviePlayerViewControllerAnimated:mp];
于 2012-06-27T10:27:02.290 回答