How do I pan audio in iOS when using the phone's speakers? AVAudioPlayer's pan works only when connected to headphones/external speakers

How do I pan audio in iOS? I've successfully used AVAudioPlayer's pan to work but only when connected to headphones/external speakers.


I have an audio file with a voice singing a melody in one channel and piano playing the same melody in the other channel. When I set pan to -1.0 and use headphones/external speakers, I get the correct behavior: only the voice or piano can be heard performing the melody, but not both. However, without anything plugged in (using the phone's speakers), I hear both channels regardless of whatever value I set for the pan.


I've attached the mp3 I used: https://drive.google.com/open?id=1BYUymcBU8mfz7PVeCF2446xZw5fU4e3G

Replies

To reproduce the issue most simply, I've set up a project here: https://github.com/euphonialabs/iOSPanDemo


To test, simply press "Play" with and without headphones/external speakers connected. The difference is obvious.