我正在尝试在webrtc for mac中提供RTCMTLNSVideoView,以填充整个容器视图(videoContainerView
是容器NSView,rtcTrack
是RTCVideoTrack)
let videoView = RTCMTLNSVideoView(frame: .zero)
videoView.frame = videoContainerView.bounds
videoView.makeBackingLayer()
videoView.layer = CAMetalLayer()
videoView.wantsLayer = true
videoView.layer?.backgroundColor = NSColor.red.cgColor
videoView.layer?.contentsGravity = .resizeAspectFill
rtcTrack?.add(videoView)
videoContainerView.addSubview(videoView)
它的结果是视频只适合使用一个大小(aspectFit)。我似乎不能使它充满整个容器。iOS webrtc有一个属性videoContentMode
。在mac上它是失踪。如何控制视频内容模式在这种情况下在mac webrtc?任何想法感谢。
谢谢
1条答案
按热度按时间bcs8qyzn1#
轻松修复:
老三回答:
正如我在评论中所说的,你必须访问私有属性
metalView
。为此,请使用以下代码在项目中创建名为
RTCMTLNSVideoView+Private.h
的文件然后您可以重新指定内容模式: