MediaEventsListener. This listener provides callbacks for your own audio/video state changes, recording events, screen sharing, audio mode changes, and camera facing changes.
Prerequisites
- An active call session
- Access to the
CallSessioninstance
Register Listener
Register aMediaEventsListener to receive media event callbacks:
- Kotlin
- Java
The listener is automatically removed when the
LifecycleOwner (Activity/Fragment) is destroyed, preventing memory leaks.Callbacks
onAudioMuted
Triggered when your local audio is muted.- Kotlin
- Java
- Update mute button icon/state
- Show muted indicator in UI
- Sync UI with actual audio state
onAudioUnMuted
Triggered when your local audio is unmuted.- Kotlin
- Java
- Update mute button icon/state
- Hide muted indicator
- Sync UI with actual audio state
onVideoPaused
Triggered when your local video is paused.- Kotlin
- Java
- 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.- Kotlin
- Java
- Update video toggle button state
- Show local video preview
- Sync UI with actual video state
onRecordingStarted
Triggered when session recording starts.- Kotlin
- Java
- Display recording indicator (red dot)
- Update recording button state
- Show notification to participants
onRecordingStopped
Triggered when session recording stops.- Kotlin
- Java
- Hide recording indicator
- Update recording button state
- Show recording saved notification
onScreenShareStarted
Triggered when you start sharing your screen.- Kotlin
- Java
- Update screen share button state
- Show “You are sharing” indicator
- Minimize local video preview
onScreenShareStopped
Triggered when you stop sharing your screen.- Kotlin
- Java
- 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).- Kotlin
- Java
Use Cases:
- Update audio mode button icon
- Show current audio output device
- Handle Bluetooth connection/disconnection
onCameraFacingChanged
Triggered when the camera facing changes (front/back).- Kotlin
- Java
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:- Kotlin
- Java
Callbacks Summary
Next Steps
Button Click Listener
Handle UI button click events
Audio Controls
Control audio programmatically