Skip to main content

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 DyteSetupViewController or built with DyteParticipantTileView and DyteSettingViewController 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

// Mute Audio
meeting.localUser.disableAudio()

// Unmute Audio
meeting.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:

extension MeetingViewModel: DyteSelfEventsListener {
func onAudioUpdate(audioEnabled: Boolean) {
// Show a visual preview of the audio to the user if enabled
}
}

2. Enable/Disable camera

// Disable Video
meeting.localUser.disableVideo()

// Enable Video
meeting.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:

extension MeetingViewModel: DyteSelfEventsListener {
func onVideoUpdate(videoEnabled: 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:

// Get all audio devices
let audioDevices = meeting.localUser.getAudioDevices()

// Get all video devices
let videoDevices = meeting.localUser.getVideoDevices()

To get the currently selected media device, use the following methods:

// Get current audio device being used
let currentAudioDevice = meeting.localUser.getSelectedAudioDevice()

// Get current video device being used
let 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]