Skip to main content
Version: 3.x.x

Pause/Resume Video Stream - Android

To stop or resume receiving a participant's streams (webcam, screen share and mic), use the pause() and resume() methods.

note
  • pause() and resume() are suspend functions. Call them from a coroutine, such as lifecycleScope.launch (from androidx.lifecycle:lifecycle-runtime-ktx), and catch the VideoSDKException they throw when a call is refused or fails.
  • They work only on the streams of a remote participant that this device receives. Calling them on your own streams throws.

Pause video stream​

  • pause() pauses a stream (webcam, screen share or mic) of a particular participant.
btnPause!!.setOnClickListener { _: View? ->
lifecycleScope.launch {
// Copy the streams: the map changes as streams start and stop
for (stream in participant.streams.values.toList()) {
try {
stream.pause()
} catch (e: VideoSDKException) {
Log.e("VideoSDK", "pause() failed for ${stream.kind}: ${e.code} ${e.name}")
}
}
}
}

Resume video stream​

  • resume() resumes a stream (webcam, screen share or mic) of a particular participant.
btnResume!!.setOnClickListener { _: View? ->
lifecycleScope.launch {
for (stream in participant.streams.values.toList()) {
try {
stream.resume()
} catch (e: VideoSDKException) {
Log.e("VideoSDK", "resume() failed for ${stream.kind}: ${e.code} ${e.name}")
}
}
}
}

Got a Question? Ask us on discord