iOS6 and MPMoviePlayerController - Black View

一个人想着一个人 提交于 2019-12-30 11:51:09

问题


I have a MPMoviePlayerController that plays a video embedded within a View. This worked perfectly on iOS5/5.1 etc... but since upgrading to iOS6 this has stopped working and now the view is just black. Does anyone have any ideas or similar issues?

Thanks


回答1:


Try this one......

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];



回答2:


I was access to the same problem, and finally finding that the key line "[player prepareToPlay]" missing. in iOS5 it does no matters, but in iOS6 it lead to a black screen;

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];



回答3:


Actually, MPMediaTypeMusicVideo is defined as MPMediaType, below is the definition: MPMediaTypeMusicVideo = 1 << 11, (2048)

Is it the undocumented thing?



来源:https://stackoverflow.com/questions/12633080/ios6-and-mpmovieplayercontroller-black-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!