0

我正在使用 twilio 发送视频并在场景包中使用该视频作为纹理。但问题是它在 iPhone X 上运行良好,但Unsupported IOSurface format: 0x26424741在 iPhone XR 和 XS 上却出现了这个错误。

这就是我正在做的事情:

获取视频:

func subscribed(to videoTrack: TVIRemoteVideoTrack, publication: TVIRemoteVideoTrackPublication, for participant: TVIRemoteParticipant) {
    print("Participant \(participant.identity) added a video track.")
    let remoteView = TVIVideoView.init(frame: UIWindow().frame,
                                       delegate:self)
    videoTrack.addRenderer(remoteView!)
    delegate.participantAdded(with: remoteView!)
}

代表:

func participantAdded(with videoView: UIView) {
    sceneView.addVideo(with: videoView)
}

并将视频添加到飞机:

func addVideo(with view: UIView){
    videoPlane.geometry?.firstMaterial?.diffuse.contents = view
}
4

1 回答 1

1

问题实际上出在renderingTypeof 上remoteView。对于较旧的设备使用metal很好,但它需要较新的设备openGLES。我不知道为什么,但它是修复。

我使用这个解决方案来找出设备类型。

接下来我确定renderingType了使用哪个

var renderingType: VideoView.RenderingType {
    get{
        let device = UIDevice()
        switch device.type{
        case .iPhoneXS:
            return .openGLES
        case .iPhoneXR:
            return .openGLES
        case .iPhoneXSMax:
            return .openGLES
        default:
            return .metal
        }
    }
}

并用它来初始化remoteView

func didSubscribeToVideoTrack(videoTrack: RemoteVideoTrack, publication: RemoteVideoTrackPublication, participant: RemoteParticipant) {
    print("Participant \(participant.identity) added a video track.")
    let remoteView = VideoView.init(frame: UIWindow().frame,
                                    delegate:self,
                                    renderingType: renderingType)
    videoTrack.addRenderer(remoteView!)
    delegate.participantAddedVideo(for: participant.identity, with: remoteView!)
}
于 2019-07-18T09:04:47.763 回答