更改视频 iPad/iPhone 的背景颜色
使用以下方法播放视频:(使用#import框架)
MPMoviePlayerController *player;
-(IBAction) playMovie: (NSString*) videoName ViedeoType:(NSString*) videoType{
ViewVideoSubview.alpha = 0;
NSString *url = [[NSBundle mainBundle]
pathForResource:videoName
ofType:videoType];
player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
[ViewVideoSubview addSubview:player.view];
....
....
}
并且视频播放正常。我想知道是否可以将视频的背景颜色从黑色更改为白色?
视频在黑色矩形中播放:
我尝试过类似 player.backgroundView.alpha = 的内容0;
但这并没有起作用。
编辑:
我也尝试过:
[[player backgroundView] setBackgroundColor:[UIColor whiteColor]];
这改变了背景颜色,但改变了视频和player.view之间的区域
with the following method I play a video: (using the #import framework)
MPMoviePlayerController *player;
-(IBAction) playMovie: (NSString*) videoName ViedeoType:(NSString*) videoType{
ViewVideoSubview.alpha = 0;
NSString *url = [[NSBundle mainBundle]
pathForResource:videoName
ofType:videoType];
player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
[ViewVideoSubview addSubview:player.view];
....
....
}
and the video plays fine. I am wondering if it possible to change the background color of the video from black to white?
the video plays in the black rectangle:
I have tried stuff like player.backgroundView.alpha = 0;
but that has not worked.
EDIT :
I have also tried:
[[player backgroundView] setBackgroundColor:[UIColor whiteColor]];
and that changes the background color but the area between the video and the player.view
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的问题有点含糊,因此我不确定我的答案是否匹配...
要更改在电影尚未完全加载/播放时显示的视频视图的颜色:
注意:如果不重新编码视频本身,则无法更改部分编码视频数据。
Your question is a bit ambiguous, hence I am uncertain if my answer matches...
To change the color of the video-view that is showing as long as the movie is not yet fully loaded/playing:
Note: It is not possible to change part of the encoded video data without reencoding the video itself.
moviePlayerViewController.view.backgroundColor = [UIColor blackColor]
UPD:我唯一可以推荐的是切换到低级别 AV Foundation。您将能够控制您需要的所有图层。
moviePlayerViewController.view.backgroundColor = [UIColor blackColor]
UPD: the only thing that I can recommend is switching to low level AV Foundation. You will be able to control all the layers you need.
您可以更改背景颜色,将playerController添加到当前视图层次结构后插入以下代码:
you can change the background color, after adding the playerController into the current view hierarchy insert the code below: