How can I replace the following lines of code (Xcode complains AudioSessionSetProperty
is deprecated as of iOS 7):
UInt32 doChangeDefaultRoute = 1;
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof(doChangeDefaultRoute), &doChangeDefaultRoute);
You'll want to do something like
AVAudioSession *audioSession; // get your audio session somehow
BOOL success = [audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&error];
if(!success)
{
NSLog(@"error doing outputaudioportoverride - %@", [error localizedDescription]);
}
This API is available in iOS 6 & newer iOS versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With