Video View
Renders one participant's camera or screen share.
Add it to a layout as <live.videosdk.rtc.android.VideoView /> or construct it in code, then hand it the track of a MediaType.VIDEO or MediaType.SHARE:
participant.addEventListener(object : ParticipantEventListener() {
override fun onStreamEnabled(stream: RTCStream) {
if (stream.kind == MediaType.VIDEO) {
videoView.addTrack(stream.track as VideoTrack)
}
}
override fun onStreamDisabled(stream: RTCStream) {
if (stream.kind == MediaType.VIDEO) videoView.removeTrack()
}
})Three rules keep tiles from going black or leaking:
Call removeTrack before giving the view a different participant's track. Re-adding the same participant's track is a cheap no-op, so a recycled tile or a recomposition costs nothing, but switching participants without detaching first can leave the old source still drawing.
Call releaseSurfaceViewRenderer exactly once, from onDestroy or a Compose DisposableEffect. It detaches the track for you, so removeTrack first is optional. The view renders nothing afterwards.
Never call the inherited SurfaceViewRenderer.release() — it can deadlock against frames still in flight. releaseSurfaceViewRenderer orders the teardown for you.
Functions
Draws the local camera preview, with any video effects applied, into this view.
Stops drawing the local camera preview into this view.
Detaches any track and frees the renderer's graphics resources, for onDestroy or a Compose DisposableEffect.
Detaches the current track and stops rendering.
Hands decoded frames to your own renderer instead of drawing them in this view.
Sets how the video is fitted into the bounds of this view.