Skip to main content
Version: 5.x.x

Participant Video Stream - Flutter

  • Using this feature, you can pause/resume participant's video stream.

  • Pausing stops the stream for you only. The participant keeps sending it to everyone else. Only streams you receive from other participants can be paused.

  • pause() and resume() return a Future that throws a VideoSDKError when the SDK refuses the call, for example 3054 if the stream is already paused or not paused.

Pause video stream​

  • pause() method is used to pause videostream of a participant.
ElevatedButton(
child: Text("Pause Video"),
onPressed: () async {
List<RTCStream> streams = participant.streams.values.where((e) => e.kind == MediaType.VIDEO).toList();

if(streams.length != 0){
RTCStream videoStream = streams[0];
try {
await videoStream.pause();
} on VideoSDKError catch (error) {
print("pause failed: ${error.code} ${error.name}");
}
}
}
),

Resume video stream​

  • resume() method is used to resume videostream of a participant.
ElevatedButton(
child: Text("Resume Video"),
onPressed: () async {
List<RTCStream> streams = participant.streams.values.where((e) => e.kind == MediaType.VIDEO).toList();

if(streams.length != 0){
RTCStream videoStream = streams[0];
try {
await videoStream.resume();
} on VideoSDKError catch (error) {
print("resume failed: ${error.code} ${error.name}");
}
}
}
),

Events​

Event associated with pause():

  • streamPaused event will be emitted on the room, and on the participant whose stream was paused, with the stream's kind and the reason.

Event associated with resume():

  • streamResumed event will be emitted on the room, and on the participant whose stream was resumed, with the stream's kind and the reason.

Listen with participant.on() to know whose stream it was. The room's handler does not say.

room.on(Events.streamPaused, (String? kind, String? reason) {
if (kind == "video") {
//a video stream was paused
}
});
room.on(Events.streamResumed, (String? kind, String? reason) {
if (kind == "video") {
//a video stream was resumed
}
});

Got a Question? Ask us on discord