MPMoviePlayerViewController 视频播放黑屏
今天用视频做本地视频播放;使用 MPMoviePlayerViewController 老是出现黑屏;
结果发现是一个 很坑爹的问题;
那就是 在 controller里面要有一个属性 MPMoviePlayerViewController *player;
.h文件
1 |
@property
( nonatomic ,retain)MPMoviePlayerViewController *videoPlayer; |
.m文件
1
2
3
4
5
6
7 |
self .videoPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:_videoFileUrl]; videoPlayer.view.frame = self .view.bounds; [videoPlayer.moviePlayer setScalingMode:MPMovieScalingModeFill]; videoPlayer.moviePlayer.controlStyle=MPMovieControlStyleEmbedded; [ self .view addSubview:videoPlayer.view]; [videoPlayer.moviePlayer prepareToPlay]; |
之前是一直是黑屏,还以为是url的问题;
结果,这也太坑爹了,必须要设置 videoPlayer 为属性;
参考:http://hi.baidu.com/shinekrad/item/8c722e04e93c0419eafe3824
二:推荐几个替代
MPMoviePlayerViewController 的库
https://github.com/alobi/ALMoviePlayerController
https://github.com/NOUSguide/NGMoviePlayer
MPMoviePlayerViewController 视频播放黑屏,布布扣,bubuko.com
MPMoviePlayerViewController 视频播放黑屏
原文:http://www.cnblogs.com/cocoajin/p/3582034.html