AudioServicesPlaySystemSound does not work on iphone while card reader is connected

I am using a card reader for the iPhone and I need to play sound while the reader is connected. Due to some other issues, I used AudioServicesPlaySystemSound. But the sound does not play through the speaker when the reader is connected.

Are there any methods to change the audio channel to a speaker when using AudioServicesPlaySystemSound?


UInt32 doChangeDefaultRoute = 1; AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof (doChangeDefaultRoute), &doChangeDefaultRoute ); 

I tried the code above. This shows strange behavior. I have observed the following cases:

  • case 1: Connected to a reader and tried to play a sound. Could not play sound.
  • case 2: Detach the reader and play the sound through the speaker once. Then connect the reader and try to play the same sound. It is working!

But I need to play sound in both cases.

Note. Instead of a card reader, you can use any device with an audio jack. You can even use a head set.

+4
source share
1 answer

You can try replacing the sound with a speaker:

 UInt32 doChangeDefaultRoute = 1; AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof (doChangeDefaultRoute), &doChangeDefaultRoute ); 
0
source

All Articles