cocos-engine icon indicating copy to clipboard operation
cocos-engine copied to clipboard

ios videoplayer层级设置

Open he-yf opened this issue 1 year ago • 6 comments

Cocos Creator version

3.8.2

System information

ios 17.4

Issue description

  在videoplayer之上自定义控件,我需要修改video的层级:我发现ui渲染似乎是指定到root层渲染,而非 _viewController.view,不知道有没有渲染层的图层的设置方法

Relevant error log output

No response

Steps to reproduce

以下是我的修改代码: // root层 UIViewController* uiVc = [[UIViewController alloc] init]; uiVc.view = [[View alloc] initWithFrame:bounds];

    // 视频层
    _videoView = [[UIView alloc] initWithFrame:bounds];
    _videoView.tag = 1001;
    [uiVc.view addSubview: _videoView];
    
    // cocos层
    UIView *cocosView = _viewController.view;
    cocosView.opaque = NO;
    cocosView.backgroundColor = [UIColor clearColor];
    [uiVc.view addSubview: cocosView];
    [self.window setRootViewController:uiVc];
    [self.window makeKeyAndVisible];
    
    // videoPlayer-ios.mm
    auto rootView = UIApplication.sharedApplication.delegate.window.rootViewController.view;
  UIView *targetView = [rootView viewWithTag:1001];
  [targetView addSubview:self.playerController.view];
  
  显示为cocosView添加与否都不影响ui渲染

Minimal reproduction project

No response

he-yf avatar Mar 28 '24 02:03 he-yf

xcode_ios_change 暂时手动给_viewController.view加了tag,强制修改,但感觉后续版本升级维护起来不太方便,还是希望能出个修改接口

he-yf avatar Mar 28 '24 06:03 he-yf

@he-yf 请问怎么把cocos层设置为背景透明?我现在把video层改到cocos层下面去了,但是会被黑色背景遮住,看不到视频,谢谢!

skymancnwu avatar May 11 '24 09:05 skymancnwu

@he-yf 请问怎么把cocos层设置为背景透明?我现在把video层改到cocos层下面去了,但是会被黑色背景遮住,看不到视频,谢谢!

cocosView.opaque = NO; cocosView.backgroundColor = [UIColor clearColor];这个部分就是

he-yf avatar May 11 '24 10:05 he-yf

好的,非常感谢!还有再请教下,SystemWindow::getWindowHandle()里的tag 1002是cocosView的tag吗?多谢!

skymancnwu avatar May 13 '24 04:05 skymancnwu

好的,非常感谢!还有再请教下,SystemWindow::getWindowHandle()里的tag 1002是cocosView的tag吗?多谢!

是的

he-yf avatar May 13 '24 05:05 he-yf

好的,非常感谢!

skymancnwu avatar May 13 '24 07:05 skymancnwu