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 DyteSetupFragment or built with DyteParticipantTileView
and DyteSettingsFragment components.
Properties
meeting.localUser.audioEnabled: A boolean value indicating if the audio currently enabled.meeting.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
- Kotlin
- Java
// Mute Audio
meeting.localUser.disableAudio {}
// Unmute Audio
meeting.localUser.enableAudio {}
// Mute Audio
meeting.localUser.disableAudio(error -> null);
// Unmute Audio
meeting.localUser.enableAudio(error -> null);
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:
- Kotlin
- Java
meeting.addSelfEventsListener(object : DyteSelfEventsListener {
override fun onAudioUpdate(isEnabled: Boolean) {
// Show a visual preview of the audio to the user if enabled
}
})
meeting.addSelfEventsListener(new DyteSelfEventsListener() {
@Override
public void onAudioUpdate(boolean isEnabled) {
// Show a visual preview of the audio to the user if enabled
}
});
2. Enable/Disable camera
- Kotlin
- Java
// Disable Video
meeting.localUser.disableVideo {}
// Enable Video
meeting.localUser.enableVideo {}
// Disable Video
meeting.localUser.disableVideo(error -> null);
// Enable Video
meeting.localUser.enableVideo(error -> null);
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:
- Kotlin
- Java
meeting.addSelfEventsListener(object : DyteSelfEventsListener {
override fun onVideoUpdate(isEnabled: Boolean) {
// Show local user's VideoView if video is enabled
}
})
meeting.addSelfEventsListener(new DyteSelfEventsListener() {
@Override
public void onVideoUpdate(boolean isEnabled) {
// 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:
- Kotlin
- Java
// Get current audio device being used
val currentAudioDevice = meeting.localUser.getSelectedAudioDevice()
// Get current video device being used
val currentVideoDevice = meeting.localUser.getSelectedVideoDevice()
// Get current audio device being used
DyteAudioDevice currentAudioDevice = meeting.localUser.getSelectedAudioDevice();
// Get current video device being used
DyteVideoDevice 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
- Kotlin
- Java
// Set audio device
meeting.localUser.setAudioDevice(device)
// eg. device = audioDevices[0]
// Set video device
meeting.localUser.setVideoDevice(device)
// eg. device = videoDevices[0]
// Set audio device
meeting.localUser.setAudioDevice(device);
// eg. device = audioDevices.get(0)
// Set video device
meeting.localUser.setVideoDevice(device);
// eg. device = videoDevices.get(0)