Video View
class VideoView : SurfaceViewRenderer
A view component for rendering video tracks from participants.
VideoView extends SurfaceViewRenderer and provides a simplified API for attaching and detaching VideoTracks. It handles initialization, track management, and cleanup automatically.
Use this view in your XML layouts or create it programmatically, then call addTrack to start rendering and removeTrack to stop.
Code Example:
// In XML:
// <live.videosdk.rtc.android.VideoView
// android:id="@+id/videoView"
// android:layout_width="match_parent"
// android:layout_height="match_parent" />
// In code:
val videoView = findViewById<VideoView>(R.id.videoView)
participant.addEventListener(object : ParticipantEventListener() {
override fun onStreamEnabled(stream: Stream) {
if (stream.kind.equals("video", ignoreCase = true)) {
val videoTrack = stream.track as VideoTrack
videoView.addTrack(videoTrack)
}
}
override fun onStreamDisabled(stream: Stream) {
if (stream.kind.equals("video", ignoreCase = true)) {
videoView.removeTrack()
}
}
})
Content copied to clipboard
See also
Stream.getTrack()
Constructors
Functions
Link copied to clipboard
Link copied to clipboard
This method can be used to release the surface view renderer and free associated resources.
Link copied to clipboard
This method can be used to detach the currently attached video track from this view.
Link copied to clipboard
This method can be used to set the scaling type for how the video frame fits within the view.