加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iphone – MPMoviePlayerController存在黑色背景

发布时间:2020-12-14 17:18:05 所属栏目:百科 来源:网络整理
导读:我制作iOS应用程序. 我使用MPMoviePlayerController,但这显示黑色背景. 我认为这个问题可以通过这个URL解决,但我无法理解使用方式. MPMoviePlayerController background color won’t stick 我的代码是这样的. NSString *path = [[NSBundle mainBundle] path
我制作iOS应用程序.

我使用MPMoviePlayerController,但这显示黑色背景.

我认为这个问题可以通过这个URL解决,但我无法理解使用方式.
MPMoviePlayerController background color won’t stick

我的代码是这样的.

NSString *path = [[NSBundle mainBundle] pathForResource:@"movie_files" ofType:@"m4v"];
NSURL *videoURL = [NSURL fileURLWithPath:path];

moviePlayer =  [[MPMoviePlayerController alloc]
                initWithContentURL:videoURL];

//setting
moviePlayer.scalingMode =MPMovieScalingModeAspectFit;
moviePlayer.controlStyle=MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay=NO;
[moviePlayer.view setFrame:CGRectMake(20,20,280,200)];    

//notification
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:moviePlayer];

//clearColor
UIView *subV =[[UIView alloc]init];
for(subV in moviePlayer.backgroundView.subviews) {
    subV.backgroundColor = [UIColor clearColor];
}
[moviePlayer.view addSubview:subV];    
[self.view addSubview:moviePlayer.view];
//show white screen

请告诉清楚的背景方式.

解决方法

您需要将其更改为:

moviePlayer.backgroundView.backgroundColor = [UIColor clearColor];
for(UIView *aSubView in moviePlayer.view.subviews) {
    aSubView.backgroundColor = [UIColor clearColor];
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读