Skip to main content
Monitor local media state changes with MediaEventListeners. This listener provides callbacks for your own audio/video state changes, recording events, screen sharing, audio mode changes, and camera facing changes.

Prerequisites

Register Listener

Register a MediaEventListeners to receive media event callbacks:
Flutter listeners are not lifecycle-aware. You must manually remove listeners in your widget’s dispose() method to prevent memory leaks.

Callbacks

onAudioMuted

Triggered when your local audio is muted.
Use Cases:
  • Update mute button icon/state
  • Show muted indicator in UI
  • Sync UI with actual audio state

onAudioUnMuted

Triggered when your local audio is unmuted.
Use Cases:
  • Update mute button icon/state
  • Hide muted indicator
  • Sync UI with actual audio state

onVideoPaused

Triggered when your local video is paused.
Use Cases:
  • Update video toggle button state
  • Show avatar/placeholder in local preview
  • Sync UI with actual video state

onVideoResumed

Triggered when your local video is resumed.
Use Cases:
  • Update video toggle button state
  • Show local video preview
  • Sync UI with actual video state

onRecordingStarted

Triggered when session recording starts.
Use Cases:
  • Display recording indicator (red dot)
  • Update recording button state
  • Show notification to participants

onRecordingStopped

Triggered when session recording stops.
Use Cases:
  • Hide recording indicator
  • Update recording button state
  • Show recording saved notification

onScreenShareStarted

Triggered when you start sharing your screen.
Use Cases:
  • Update screen share button state
  • Show “You are sharing” indicator
  • Minimize local video preview

onScreenShareStopped

Triggered when you stop sharing your screen.
Use Cases:
  • Update screen share button state
  • Hide “You are sharing” indicator
  • Restore local video preview

onAudioModeChanged

Triggered when the audio output mode changes (speaker, earpiece, bluetooth).
AudioMode Values: Use Cases:
  • Update audio mode button icon
  • Show current audio output device
  • Handle Bluetooth connection/disconnection

onCameraFacingChanged

Triggered when the camera facing changes (front/rear).
CameraFacing Values: Use Cases:
  • Update camera switch button icon
  • Adjust UI for mirrored/non-mirrored preview
  • Track camera state

Complete Example

Here’s a complete example handling all media events:

Remove Listener

Remove the listener in your widget’s dispose() method to prevent memory leaks:

Callbacks Summary

Next Steps

Button Click Listener

Handle UI button click events

Audio Controls

Control audio programmatically