4.2 C
New York
Friday, November 22, 2024

swift – Easy methods to Stop WebRTC Audio and Mapbox Navigation Audio from Interrupting Every Different in iOS?


I’m engaged on an iOS app that integrates:

WebRTC for a voice communication module.
Mapbox Navigation SDK for turn-by-turn navigation audio.
The problem I am going through is that when Mapbox Navigation, which makes use of SDK’s UI NavigationViewController, performs audio directions (e.g., “Flip left in 100 meters”), it interrupts and stops the audio of the continuing WebRTC voice communication. This conduct negatively impacts the consumer expertise since each real-time communication and navigation are essential to the app.

Right here is the WebRTC audio session setup I’m utilizing for the voice communication module:

func setupAudioSession() {
    self.rtcAudioSession.lockForConfiguration()
    do {
        print(self.rtcAudioSession.categoryOptions)
        strive self.rtcAudioSession.setCategory(AVAudioSession.Class.playAndRecord.rawValue, with: [.mixWithOthers])
        strive self.rtcAudioSession.setMode(AVAudioSession.Mode.voiceChat.rawValue)
        strive self.rtcAudioSession.overrideOutputAudioPort(.speaker)
    } catch let error {
        debugPrint("Error altering AVAudioSession class: (error)")
    }
    self.rtcAudioSession.unlockForConfiguration()
}

This configuration permits the WebRTC audio stream to work completely in isolation.

When Mapbox Navigation begins taking part in an audio instruction, it appears to reconfigure AVAudioSession and adjustments it is mode to AVAudioSessionModeDefault whereas WebRTC set it to AVAudioSessionModeVoiceChat beforehand, inflicting WebRTC audio to cease.
After the Mapbox audio finishes, WebRTC audio doesn’t get better its unique state.

My Objective

I need each WebRTC voice communication and Mapbox Navigation audio to work concurrently with out interruptions. WebRTC audio shouldn’t cease after Mapbox performed directions.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles