Skip to main content
Version: 5.x.x

Stream Events - Flutter

Each RTCStream reports changes in its state with the streamStateChanged event. Use it to show when a remote participant's video or screen share is frozen or stuck.

Events.streamStateChanged​

  • It is delivered on the stream, not on the Room. Subscribe with stream.on() and remove the handler with stream.off().
  • The handler receives the new state as a StreamState and a timestamp, in milliseconds since the epoch.
  • The state is one of StreamState.ACTIVE, ENDED, STUCK, FREEZE_DETECTED and FREEZE_RESOLVED.
  • A new stream's first ACTIVE arrives about one second after the stream is enabled. A state that arrives sooner replaces it.

Example​

import 'package:videosdk/videosdk.dart';

void watchStream(Room room) {
room.on(Events.streamEnabled, (RTCStream stream) {
if (stream.kind == MediaType.AUDIO) return;
stream.on(Events.streamStateChanged, (StreamState state, int timestamp) {
print("${stream.participantId}'s ${stream.kind.name} stream is ${state.name}");
});
});
}

To know when a stream is enabled, disabled, paused or resumed, listen on the Room as shown in Media Events.

Got a Question? Ask us on discord