2

I want to direct iOS VoiceOver sound to headphone even if it's not plugged in.

In other words, while my app is open, VoiceOver sound (and other sounds played by me in app using AVSpeechUtterance etc.) should NEVER go to speakers, but should come out of headset, if connected.

Can anyone suggest something on this?

Maverick
  • 3,209
  • 1
  • 34
  • 40

2 Answers2

1

iOS devices will not power-up the headset jack for audio output unless a recognized (proper impedance, etc.) headset or headphone is currently plugged in to the jack.

VoiceOver audio will always go to the headset, if a valid one is plugged-in, and not over-ridden.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • Thank you for your response. My actual concern is to block audio from going to loud speaker when headset isn't connected, which i've achieved now by directing the audio to phone speaker (from where you listen to phone call) from loud speaker while my app is running. I used following code: `let session: AVAudioSession = AVAudioSession.sharedInstance() try session.setCategory(AVAudioSessionCategoryPlayAndRecord) try session.overrideOutputAudioPort(AVAudioSessionPortOverride.None) try session.setActive(true)` – Maverick Feb 28 '16 at 13:00
1

Apparently it's not possible to forcefully direct sound to headphone unless an accessory is plugged to headphone jack (which activates a physical switch to direct voice to headphone).

I've achieved my purpose using following code (in Swift) which directs VoiceOver and other sounds to phone speaker (from where we listen to phone calls) and silences loud speaker while my app is in foreground.

let session: AVAudioSession = AVAudioSession.sharedInstance()
do {
    try session.setCategory(AVAudioSessionCategoryPlayAndRecord)
    try session.overrideOutputAudioPort(AVAudioSessionPortOverride.None)
    try session.setActive(true)
} catch {
    print("Couldn't override output audio port")
}
Zev Eisenberg
  • 8,080
  • 5
  • 38
  • 82
Maverick
  • 3,209
  • 1
  • 34
  • 40