This message was deleted.
# helpdesk
s
This message was deleted.
m
cc @better-house-11852
b
This might be helpful to understand our integration
Copy code
do {
            try audioSession.setCategory(.playback, mode: .default, options: [
                .allowBluetoothA2DP,
                .mixWithOthers,
            ])
        } catch {
        }

        AudioManager.shared.customConfigureAudioSessionFunc = { newState, oldState in
            // Gets called when a new track gets published
            // Happens when a Local or Remote Participant first joines the call and unmutes
            DispatchQueue.main.async {
                let configuration = RTCAudioSessionConfiguration.webRTC()

                if [.localOnly, .localAndRemote].contains(newState.trackState) && ![.localOnly, .localAndRemote].contains(oldState.trackState) {
                    configuration.categoryOptions = [
                        .allowBluetooth,
                        .mixWithOthers,
                    ]
                    configuration.category = AVAudioSession.Category.playAndRecord.rawValue
                    configuration.mode = AVAudioSession.Mode.videoChat.rawValue
                } else {
                    // If this is on, music is always ducked when some other participant is unmuted
                    configuration.categoryOptions = [
                        .allowBluetoothA2DP,
                        .mixWithOthers,
                    ]
                    configuration.category = AVAudioSession.Category.playback.rawValue
                    configuration.mode = AVAudioSession.Mode.default.rawValue
                }
            }
        }
Copy code
private func setMute(_ value: Bool) {
        guard let localParticipant = room.localParticipant else {
            log.error("LocalParticipant doesn't exist")
            return
        }

        guard !microphoneTrackState.isBusy else {
            log.warning("microphoneTrack is .busy")
            return
        }

        DispatchQueue.main.async {
            self.microphoneTrackState = .busy(isPublishing: !self.microphoneTrackState.isPublished)
        }

        localParticipant.setMicrophone(enabled: value).then { publication in
            guard let publication = publication else { return }

            DispatchQueue.main.async {
                self.microphoneTrackState = .published(publication)
                if publication.muted {
                    _ = localParticipant.unpublish(publication: publication)
                }

                self.log.verbose("Microphone is now \(publication.muted ? "Muted" : "NOT Muted")")
            }
        }.catch { error in
            DispatchQueue.main.async {
                self.microphoneTrackState = .notPublished(error: error)
            }
            self.log.verbose("Failed to publish microphone, error: \(error)")
        }
    }
@better-house-11852 Shall I also create a github issue or is this fine?
@better-house-11852 https://github.com/livekit/client-sdk-swift/issues/236 @dry-elephant-14928 asked me to file an github issue. So I did 🙂 Feel free to ask me anything