Skip to main content
Version: 5.x.x

RTCStream Class Methods - Flutter

resume()​

  • By using resume(), a participant can resume the stream of Remote Participant.

  • It starts receiving a stream again after pause() stopped it.

Returns​

  • Future<void> that completes once the stream is resumed.

Throws​

  • VideoSDKError if the SDK refuses or the request fails, for example:
    • 3054 (ERROR_ALREADY_IN_REQUESTED_STATE) if the stream is not paused.
    • 3065 (ERROR_ROOM_RECONNECTING) while the room reconnects.
    • 3068 (ERROR_ACTION_NOT_SUPPORTED) for your own stream.
    • 3035 (ERROR_ACTION_PERFORMED_BEFORE_ROOM_JOINED) after the room has left.
    • 4075 (RESUME_STREAM_FAILED) if the request fails.
  • See Room Error Codes for the full list.

Example​

try {
await stream.resume();
} on VideoSDKError catch (error) {
print("Could not resume the stream: ${error.code} ${error.name}");
}

pause()​

  • By using pause(), a participant can pause the stream of Remote Participant.

  • You stop receiving the stream, for example to save bandwidth while its tile is off screen. The participant keeps sending it to everyone else.

  • Only remote streams can be paused. Your own streams, where isLocal is true, cannot.

Returns​

  • Future<void> that completes once the stream is paused.

Throws​

  • VideoSDKError if the SDK refuses or the request fails, for example:
    • 3054 (ERROR_ALREADY_IN_REQUESTED_STATE) if the stream is already paused.
    • 3065 (ERROR_ROOM_RECONNECTING) while the room reconnects.
    • 3068 (ERROR_ACTION_NOT_SUPPORTED) for your own stream.
    • 3035 (ERROR_ACTION_PERFORMED_BEFORE_ROOM_JOINED) after the room has left.
    • 4074 (PAUSE_STREAM_FAILED) if the request fails.
  • See Room Error Codes for the full list.

Example​

try {
await stream.pause();
} on VideoSDKError catch (error) {
print("Could not pause the stream: ${error.code} ${error.name}");
}

on()​

  • It is used to listen to the stream's streamStateChanged event. No other event is delivered on a stream.

Parameters​

  • event: Events.streamStateChanged
  • handler: Function(StreamState state, int timestamp)

Returns​

  • void

Example​

void onStateChanged(StreamState state, int timestamp) {
print("Stream state: ${state.name}");
}

stream.on(Events.streamStateChanged, onStateChanged);

off()​

  • It removes a handler that you added with on().

Parameters​

  • event: Events.streamStateChanged
  • handler: the same function you passed to on().

Returns​

  • void

Example​

stream.off(Events.streamStateChanged, onStateChanged);

Got a Question? Ask us on discord


Was this helpful?

Not helpfulHelpful