AudioServicesPlaySystemSound not working in iphone while card-reader is plugged in

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

Is there any methods to change the audio channel to speaker while using AudioServicesPlaySystemSound?


UInt32 doChangeDefaultRoute = 1;

AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryDefaultToSpeaker,
                         sizeof (doChangeDefaultRoute),
                         &doChangeDefaultRoute
                         ); 

I have tried the above code. It shows some strange behaviour. I observed the following cases:

  • case 1: Plugged in the reader and tried to play the sound. Failed to play the sound.
  • case 2: Unplugged the reader and played the sound through speaker once. Then plug in the reader and tried to play the same sound. It works!

But I need to play the sound in both cases.

Note: Instead of card reader you can use any device with an audio jack. Even a head set can be used.

Answers


You can try to override sound output to speaker:

UInt32 doChangeDefaultRoute = 1;

AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryDefaultToSpeaker,
                         sizeof (doChangeDefaultRoute),
                         &doChangeDefaultRoute
                         );  

Need Your Help

How to better handle GPS location and android

android gps locationmanager android-location

I have a fragment with a listview in it, that retrieves the users location, then updates the list view based on the users location.

Implicit parameter in super class scope

scala implicit-conversion superclass

In my current project, we've got a trait with a method like: