更改视频 iPad/iPhone 的背景颜色

发布于 2024-11-25 13:46:24 字数 858 浏览 0 评论 0原文

使用以下方法播放视频:(使用#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:

enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

捎一片雪花 2024-12-02 13:46:24

您的问题有点含糊,因此我不确定我的答案是否匹配...

要更改在电影尚未完全加载/播放时显示的视频视图的颜色:

player.view.backgroundColor = [UIColor whiteColor];

注意:如果不重新编码视频本身,则无法更改部分编码视频数据。

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:

player.view.backgroundColor = [UIColor whiteColor];

Note: It is not possible to change part of the encoded video data without reencoding the video itself.

物价感观 2024-12-02 13:46:24

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.

乖乖公主 2024-12-02 13:46:24

您可以更改背景颜色,将playerController添加到当前视图层次结构后插入以下代码:

NSArray *subViews = [[[self playerController] view] subviews];
for(UIView *v in subViews)
{
    if([v respondsToSelector:@selector(setBackgroundColor:)])
    {
        [v setBackgroundColor:[UIColor whiteColor]];
    }
}

you can change the background color, after adding the playerController into the current view hierarchy insert the code below:

NSArray *subViews = [[[self playerController] view] subviews];
for(UIView *v in subViews)
{
    if([v respondsToSelector:@selector(setBackgroundColor:)])
    {
        [v setBackgroundColor:[UIColor whiteColor]];
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文