Skip to main content
Version: 3.x.x

Monitoring Remote Participants' Stream - Flutter

Monitoring the state of a remote participant’s stream helps ensure a consistent and high-quality meeting experience. The streamStateChanged event accessible from the Stream class provides real-time updates whenever the condition of a remote video or screenshare video stream changes — allowing your app to detect issues and respond accordingly.

By subscribing to this event, you can track when a stream becomes active, stuck, or experiences a freeze, and take corrective actions or inform users as needed.

note

This event is emitted exclusively for remote participants, specifically for their video and screen share video streams.

Why It Matters

Stream state monitoring is crucial for maintaining call reliability and diagnosing issues that affect the remote participant’s media. Using this event, you can:

  • Detect when a remote participant’s video freezes or becomes stuck.
  • Notify local participants about possible issues.
  • Log state transitions for diagnostics or quality metrics.

Example Usage

import 'package:videosdk/videosdk.dart';

class ParticipantTile extends StatefulWidget {
final Participant participant;

const ParticipantTile({
super.key,
required this.participant,
});

@override
State<ParticipantTile> createState() => _ParticipantTileState();
}

class _ParticipantTileState extends State<ParticipantTile> {
Stream? videoStream;

@override
void initState() {
super.initState();

// Initialize existing video stream (if already available)
widget.participant.streams.forEach((key, Stream stream) {
if (stream.kind == 'video') {
_setVideoStream(stream);
}
});

_initStreamListeners();
}

void _setVideoStream(Stream stream) {
setState(() {
videoStream = stream;
});

// Listen to stream state changes
videoStream?.on(
Events.streamStateChanged,
(state, timestamp) {
log("Stream state changed to $state at $timestamp");
},
);
}

void _initStreamListeners() {
widget.participant.on(
Events.streamEnabled,
(Stream stream) {
if (stream.kind == 'video') {
_setVideoStream(stream);
widget.participant.setQuality(quality);
}

},
);

}

@override
Widget build(BuildContext context) {
return Container(
// Your UI here
);
}
}

API Reference

The API references for all the methods and events utilized in this guide are provided below.

Got a Question? Ask us on discord