[英]WebRTC - iOS Swift - Remove video stream and set uiview to black
我正在實現一個使用 WebRTC(libjingle_peerconnection 庫)檢索視頻流的應用程序。 在某些時候,流 (RTCVideoTrack) 可能會被刪除。 當這種情況發生在 UIView (RTCEAGLVideoView) 中時,仍然顯示流的最后一幀。 我想將該視圖設置為黑色。 我該怎么做?
現在我正在使用以下代碼刪除流,但正如我所說,最后一幀一直顯示在視圖中。
remoteVideoTrack.setEnabled(false) // RTCVideoTrack object
remoteVideoTrack.remove(videoView) // videoView is the RTCEAGLVideoView UI object
remotePeerConnection.close()
我遇到了類似的問題。 但是,在某些情況下,黑色視圖是不可接受的,我需要渲染器視圖變得完全透明。
由於我的視頻聊天視圖控制器顯示在容器中,因此我能夠通過完全重新加載容器使渲染器的最后一幀消失。
這是相關代碼:
// Kill renderer
vcWebRtc?.willMove(toParent: nil)
vcWebRtc?.view.removeFromSuperview()
vcWebRtc?.removeFromParent()
vcWebRtc = UIStoryboard.instance(from: .WebRTC).instantiateInitialViewController() as? WebRtcVC
if vcWebRtc != nil{
addChild(vcWebRtc!)
viewWebRtcContainer.addSubview(vcWebRtc!.view)
vcWebRtc!.view.frame = viewWebRtcContainer.bounds
vcWebRtc?.didMove(toParent: self)
vcWebRtc?.delegate = self}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.