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 Dyte meeting.
If you are using our UI Kits, this functionality can be handled by DyteSetupScreen
or built with DyteParticipantTile
widget.
Properties
dyteMobileClient.localUser.audioEnabled
: A boolean value indicating if the audio currently enabled.dyteMobileClient.localUser.videoEnabled
: A boolean value indicating if the video 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
dyteMobileClient.localUser.disableAudio()
// Unmute Audio
dyteMobileClient.localUser.enableAudio()
Anytime there is an update in the audio state of the local user, the Core SDK notifies the client through the onAudioUpdate
callback
from DyteSelfEventsListener
. Here's how you can register the listener:
class SelfAudioNotifier extends DyteSelfEventsListener{
override fun onAudioUpdate(bool audioEnabled) {
// Show local user's VideoView if video is enabled
}
}
dyteMobileClient.addSelfEventsListener(SelfAudioNotifier())
2. Enable/Disable camera
// Disable Video
dyteMobileClient.localUser.disableVideo()
// Enable Video
dyteMobileClient.localUser.enableVideo()
Whenever there is an update in the video state of the local user, the Core SDK notifies the client through the onVideoUpdate
callback
from DyteSelfEventsListener
. Here's how you can register the listener:
class SelfVideoNotifier extends DyteSelfEventsListener{
override fun onVideoUpdate(bool videoEnabled) {
// Show local user's VideoView if video is enabled
}
}
dyteMobileClient.addSelfEventsListener(SelfVideoNotifier());
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:
// Get all audio devices
final audioDevices = dyteMobileClient.localUser.getAudioDevices()
// Get all video devices
final videoDevices = dyteMobileClient.localUser.getVideoDevices()
To get the currently selected media device, use the following methods:
// Get current audio device being used
final currentAudioDevice = dyteMobileClient.localUser.getSelectedAudioDevice()
// Get current video device being used
final currentVideoDevice = dyteMobileClient.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
dyteMobileClient.localUser.setAudioDevice(device)
// eg. device = audioDevices[0]
// Set video device
dyteMobileClient.localUser.setVideoDevice(device)
// eg. device = videoDevices[0]