How can I rotate the RTCEGLVideoview?

Viewed 106

I want to rotate the screen of the remote video 90 degrees. Is there any way to rotate in the client?

I know the keyword RTCVideoRotation. But I'm not sure where to apply it.

This is my VideoView to rendering.

struct VideoView: UIViewRepresentable {

    let videoTrack: RTCVideoTrack?
    @Binding var refreshVideoTrack: Bool

    func makeUIView(context: Context) -> RTCEAGLVideoView {
        let view = RTCEAGLVideoView(frame: .zero)
        view.contentMode = .scaleAspectFill
        return view
    }

    func updateUIView(_ view: RTCEAGLVideoView, context: Context) {

        if(refreshVideoTrack){
            videoTrack?.add(view)
            refreshVideoTrack = false
        }
    }
}
1 Answers

I got it.

func makeUIView(context: Context) -> RTCEAGLVideoView {
        let view = RTCEAGLVideoView(frame: .zero)
        view.rotationOverride = NSNumber(value: RTCVideoRotation._90.rawValue)
        view.contentMode = .scaleAspectFill
        return view
}
Related