0

How do I change the following line to iOS 7 compliant code?

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

kAudioSessionProperty_AudioRoute was used before iOS 5. in iOS 5-6 it should be kAudioSessionProperty_AudioRouteDescription but it is read-only. Seems this property is set incorrectly but strangely but it doesn't produce an error after I upgrade iOS deploy target to iOS 7.

newguy
  • 5,668
  • 12
  • 55
  • 95
  • http://stackoverflow.com/questions/19650585/detect-listen-to-audio-route-change-in-ios-7/19650731#19650731 – KudoCC Apr 18 '14 at 06:34
  • Thanks but that example look really cumbersome. Isn't there an easier way to do the same thing? – newguy Apr 18 '14 at 06:39

1 Answers1

0

Use [AVAudioSession sharedInstance] instead of AudioSessionSetProperty for more information you can check this on google. there are so many post exist relevant it.

Gajendra Rawat
  • 3,673
  • 2
  • 19
  • 36
  • I am using AVAudioSession, I just don't know how to change the particular line. I couldn't find any info on how to change that line without affecting any existing functionality. If you can find those links can you post one here please? – newguy Apr 18 '14 at 06:33
  • http://stackoverflow.com/questions/18807157/how-do-i-route-audio-to-speaker-without-using-audiosessionsetproperty check this one – Gajendra Rawat Apr 18 '14 at 06:41
  • This is not exactly what I need. According to [AudioRoute](http://stackoverflow.com/questions/6901363/detecting-the-iphones-ring-silent-mute-switch-using-avaudioplayer-not-worki) iOS 6 has no way to deal with such situation. The link KudoCC posted seems to do the job in iOS 7 but is too bulky. I have decided to remove the code as it is not affecting my project at the moment. – newguy Apr 18 '14 at 08:01