Skip to main content
Version: 3.x.x

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​

  • id is the Id of the stream. It is also the key of the stream in participant.streams.
  • type : String

kind​

  • kind is the kind of stream: audio (microphone), video (camera), share (screen share) or shareAudio (audio captured with the screen share).
  • Compare it ignoring case, because shareAudio is not all lower case.
  • type : String

track​

  • track is the media track of the stream, or null for an unknown kind.
  • For video and share, it is a VideoTrack. Cast it and pass it to VideoView.addTrack().
  • For audio and shareAudio, it is a handle that does not control playback. The SDK plays remote audio itself.
  • type : MediaStreamTrack? from the videosdk.org.webrtc package
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 a suspend function. Call it from a coroutine.
  • It throws VideoSDKException when the request fails: 3035 before the meeting is joined, 3065 while the meeting is reconnecting, 3068 for a stream this device is not receiving (such as your own stream), 3054 when the stream is already paused, 4074 when the server refuses the request, and 3079 when 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 that pause() stopped.
  • resume() is a suspend function. Call it from a coroutine.
  • It throws VideoSDKException with the same codes as pause(), except that 3054 means the stream is not paused and a server refusal is 4075.
  • return type : Unit

Got a Question? Ask us on discord