No audio on internal/external speaker

Hello,

I want to switch my audio session to the external speaker.
On iOS 12 it works fine but on on iOS 13.

Here is my audio setup code:

Code Block
do {
try AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .default, options: .mixWithOthers)
try AVAudioSession.sharedInstance().overrideOutputAudioPort(.speaker)
try AVAudioSession.sharedInstance().setActive(true)
} catch {
print(error)
}


This code above works fine, I start my audio session with the external speaker on the device. Now I want to switch the audio from external speaker to the internal speaker during an active session.

Therefor I use this simple line:

Code Block
try AVAudioSession.sharedInstance().overrideOutputAudioPort(.none)


The result is: on iOS12 it works fine, but on on iOS 13
Is there an API change or something else? What is my mistake? Maybe I have to use another API from ObjC or deeper one from the C layer? Or work here with AudioUnit?

For the playback I use now the AVAudioEngine (after the speaker switch it plays no audio).



No audio on internal/external speaker
 
 
Q