Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS app only plays sounds through headphones

The iPhone I'm using for development only outputs sounds through the headphones for all the apps I'm running from xcode. Other apps (like Youtube or iTunes) play sound just fine, and also building and testing the very same apps on a different device (an iPad) works perfectly. Running the apps in simulator also works as intended.

I'm using:

  • Xcode 6 (working in Swift 1.2)
  • AVFoundation library and AVAudioPlayer
  • iPhone 6 Plus (with iOS 8.4.1)
  • the phone is not in silent mode

Any tips or hints would be appreciated. Thanks

like image 761
Marius Pop Avatar asked Oct 30 '22 19:10

Marius Pop


1 Answers

Sometimes the audio route can get a bit messed up.

You should listen to the audio route changes using the AVAudioSessionRouteChangeNotification

See HandlingAudioHardwareRouteChanges

You can also force the audio route if needed. Working with Audio Input and Output Routes

Oh, and also check the reason for the change to know why its happening on that app. AVAudioSessionRouteChangeReason

like image 80
some_id Avatar answered Nov 15 '22 09:11

some_id