MPMoviePlayerController在ios 5中不起作用

时间:2012-06-27 10:22:38

标签: objective-c ios5

使用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文件中声明,但仍未处于工作状态。

1 个答案:

答案 0 :(得分: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];