Stream Class
Introduction
The Stream Class includes the properties and methods of a participant's audio, video and screen-share streams.
You get Stream objects in onStreamEnabled() and onStreamDisabled() of ParticipantEventListener, and from participant.streams. You do not create them yourself.
For the full reference, see Stream Class.
Properties
id
idis the Id of the stream. It is also the key of the stream inparticipant.streams.- type :
String
kind
kindis the kind of stream:audio(microphone),video(camera),share(screen share) orshareAudio(audio captured with the screen share).- Compare it ignoring case, because
shareAudiois not all lower case. - type :
String
track
trackis the media track of the stream, ornullfor an unknown kind.- For
videoandshare, it is aVideoTrack. Cast it and pass it toVideoView.addTrack(). - For
audioandshareAudio, it is a handle that does not control playback. The SDK plays remote audio itself. - type :
MediaStreamTrack?from thevideosdk.org.webrtcpackage
import videosdk.org.webrtc.VideoTrack
class ParticipantViewListener(private val videoView: VideoView) : ParticipantEventListener() {
override fun onStreamEnabled(stream: Stream) {
if (stream.kind.equals("video", ignoreCase = true)) {
val track = stream.track as? VideoTrack ?: return
videoView.addTrack(track)
}
}
}
Methods
pause()
- By using
pause()function, a participant can pause the stream of Remote Participant. Only this device stops receiving it; the other participants still receive it. pause()is asuspendfunction. Call it from a coroutine.- It throws
VideoSDKExceptionwhen the request fails:3035before the meeting is joined,3065while the meeting is reconnecting,3068for a stream this device is not receiving (such as your own stream),3054when the stream is already paused,4074when the server refuses the request, and3079when the server does not answer in time. - return type :
Unit
lifecycleScope.launch {
try {
stream.pause()
} catch (e: VideoSDKException) {
Log.e("VideoSDK", "pause() failed: ${e.code} ${e.name}")
}
}
resume()
- By using
resume()function, a participant can resume the stream of Remote Participant thatpause()stopped. resume()is asuspendfunction. Call it from a coroutine.- It throws
VideoSDKExceptionwith the same codes aspause(), except that3054means the stream is not paused and a server refusal is4075. - return type :
Unit
Got a Question? Ask us on discord

