Media Preview
Before joining a meeting, users may want to preview and configure their media devices like camera, microphone, and audio output. This section provides developers with the tools to prepare the media environment before joining a RealtimeKit meeting.
If you are using our UI Kits, this functionality can be handled by RtkSetupFragment
or built with RtkParticipantTileView
and RtkSettingsFragment
components.
Properties
meeting.localUser.audioEnabled
: Aboolean
value indicating if the audio is currently enabled.meeting.localUser.videoEnabled
: Aboolean
value indicating if the video is currently enabled.
Methods
Toggling Media
The same methods used for controlling media during a meeting are also applicable for pre-call media configuration.
1. Mute/Unmute microphone
// Mute Audio
meeting.localUser.disableAudio { error: AudioError? -> }
// Unmute Audio
meeting.localUser.enableAudio { error: AudioError? -> }
Anytime there is an update in the audio state of the local user, the Core SDK notifies the client through the onAudioUpdate
callback
from RtkSelfEventListener
. Here's how you can register the listener:
meeting.addSelfEventListener(object : RtkSelfEventListener {
override fun onAudioUpdate(isEnabled: Boolean) {
// Show a visual preview of the audio to the user if enabled
}
})
2. Enable/Disable camera
// Disable Video
meeting.localUser.disableVideo { error: VideoError? -> }
// Enable Video
meeting.localUser.enableVideo { error: VideoError? -> }
Whenever there is an update in the video state of the local user, the Core SDK notifies the client through the onVideoUpdate
callback
from RtkSelfEventListener
. Here's how you can register the listener:
meeting.addSelfEventListener(object : RtkSelfEventListener {
override fun onVideoUpdate(isEnabled: Boolean) {
// Show local user's VideoView if video is enabled
}
})
Changing Media Device
Media devices represent the hardware for the camera, microphone, and speaker devices. To get the list of media devices currently available, use the following methods:
To get the currently selected media device, use the following methods:
// Get current audio device being used
val currentAudioDevice = meeting.localUser.getSelectedAudioDevice()
// Get current video device being used
val currentVideoDevice = meeting.localUser.getSelectedVideoDevice()
Use these methods to create a UI that allows users to configure their media devices. When the user selects a device, use the below methods to set the device.
Set device
// Set audio device
meeting.localUser.setAudioDevice(device)
// eg. device = audioDevices[0]
// Set video device
meeting.localUser.setVideoDevice(device)
// eg. device = videoDevices[0]