Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App's audio not working through speakers

There's a weird bug in my app. I'm using AVAudioPlayer to play sounds (multiple instances of it), the sound works perfectly through headphones, but using the app without headphones produces no sound from the speaker. All of the audio clips are AAC encoded.

I have tried setting the AVAudioSession properties both through the Objective-C API ([AVAudioSession sharedInstance]) and the C API, but none of the the options seem to work.

like image 560
SiimKallas Avatar asked Jun 06 '12 20:06

SiimKallas


People also ask

Why is my speaker not working on apps?

If your Android loudspeaker won't work, restart the device and check for updates. Additionally, reset the sound settings, and disable Bluetooth and Do Not Disturb mode. If the issue persists, remove the case, clean your speaker grills, enter Safe Mode, and reset your settings.

Why is no sound coming out of my speakers?

Check sound settingsCheck to make sure your audio devices aren't muted and haven't been disabled. Select and hold (or right-click) the Speakers icon on the taskbar, and then select Open Volume mixer. Note: If you don't see Speakers displayed, it may be in the overflow area. Select Show hidden icons to check there.

Why cant I hear some apps on my PC?

No sound in one app First, reboot your computer. Confirm the program's volume isn't turned down or muted. In browsers like Chrome and Firefox, each tab can be muted individually—right-click a tab to see its status. (The option will say “Unmute tab” if currently silenced.)

Why is my Iphone Speaker not working on apps?

If you can't hear any sounds from a specific app or some apps, the problem may be in your Notification settings. Make sure that you turn on Allow Notifications and Sounds. You can check by going to Settings > Notifications and choosing the app.


3 Answers

accepted answer (in ios7) did not work for me, the following code did work. (i do not have enough points to comment, posting this as separate answer)

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord
                                 withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker
                                       error:nil];
like image 151
tmr Avatar answered Sep 20 '22 19:09

tmr


ISSUE on iPhone - when sound was very low - seemed it was coming out the phone ear piece (not headphone jack) instead of bottom speaker - change to DEFAULT TO SPEAKER

//http://stackoverflow.com/questions/3104562/avaudiorecorder-avaudioplayer-sound-output-on-internal-speaker-how-to-chang


UInt32 doChangeDefaultRoute = 1;
AudioSessionSetProperty (
    kAudioSessionProperty_OverrideCategoryDefaultToSpeaker,
    sizeof (doChangeDefaultRoute),
    &doChangeDefaultRoute
);
like image 21
brian.clear Avatar answered Sep 19 '22 19:09

brian.clear


For those of you using Swift Syntax...

Below worked for me.

do {
    try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, withOptions: AVAudioSessionCategoryOptions.DefaultToSpeaker)
   } 
catch {
          print("can't default to speaker ")
      }
like image 22
UKDataGeek Avatar answered Sep 20 '22 19:09

UKDataGeek