Skip to content

Cannot Route Audio to Speaker According to Callkit Sample Project #11

@shahnewaj-rahi

Description

@shahnewaj-rahi

In my app, I have integrated Callkit and Livekit accroding sample project here. I have a speaker toggle button in UI to let user enable/disable speaker. In button actions, I have added the following code to enable/disable speaker-

func enableSpeaker(_ enable: Bool) {
do {
try AVAudioSession.sharedInstance().overrideOutputAudioPort(enable ? .speaker : .none)
debugPrint("\(enable ? "enabled" : "disabled") speaker")
} catch {
debugPrint("failed to \(enable ? "enable" : "disable") speaker: \(error.localizedDescription)")
}
}

After this code is executed, audio input/output becomes disabled. There's no error thrown here though. How to enable speaker seamlessly keeping consistent with the callkit audio session flow in the sample project?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions