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()andresume()return aFuturethat throws aVideoSDKErrorwhen the SDK refuses the call, for example3054if 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():
streamPausedevent will be emitted on the room, and on the participant whose stream was paused, with the stream'skindand thereason.
Event associated with resume():
streamResumedevent will be emitted on the room, and on the participant whose stream was resumed, with the stream'skindand thereason.
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

