MPMoviePlayerViewController 视频播放黑屏
今天用视频做本地视频播放;使用 MPMoviePlayerViewController 老是出现黑屏;
结果发现是一个 很坑爹的问题;
那就是 在 controller里面要有一个属性 MPMoviePlayerViewController *player;
.h文件
@property (nonatomic,retain)MPMoviePlayerViewController *videoPlayer;
.m文件
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 为属性;
参考:
二:推荐几个替代
MPMoviePlayerViewController 的库