VideoView

open class VideoView : SurfaceViewRenderer

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.

Constructors

Link copied to clipboard
constructor(context: Context)
constructor(context: Context, attrs: AttributeSet?)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun addTrack(videoTrack: VideoTrack?)

Attaches a video track and starts rendering it.

fun addTrack(videoTrack: VideoTrack?, rendererEvents: RendererCommon.RendererEvents?)

Attaches a video track and reports renderer events — use it to swap a placeholder for the tile once real video arrives.

Link copied to clipboard

Draws the local camera preview, with any video effects applied, into this view.

Link copied to clipboard

Stops drawing the local camera preview into this view.

Link copied to clipboard

Detaches any track and frees the renderer's graphics resources, for onDestroy or a Compose DisposableEffect.

Link copied to clipboard

Detaches the current track and stops rendering.

Link copied to clipboard

Hands decoded frames to your own renderer instead of drawing them in this view.

Link copied to clipboard
open override fun setMirror(mirror: Boolean)

Sets whether the rendered video is mirrored horizontally.

Link copied to clipboard
open override fun setScalingType(scalingType: RendererCommon.ScalingType)

Sets how the video is fitted into the bounds of this view.