openfrog
openfrog

Reputation: 40765

How to detect ringer switch state in iOS?

I configured my audio session for kAudioSessionCategory_AmbientSound for an app which plays music with AVAudioPlayer. But problem is app also plays effects with OpenAL. I want music to play always (also in background) but OpenAL sound effects only if mute switch not muted.

Upvotes: 2

Views: 1180

Answers (2)

sounder_michael
sounder_michael

Reputation: 576

One iOS-5-compatible trick (which the source that shabzco posted uses) is to play an audio recording of a known length. If the completion handler fires sooner than expected then the mute switch is probably on.

Upvotes: 0

shabbirv
shabbirv

Reputation: 9098

There is no documented way of doing it, but you can try this project. It is an open source project that claims it can detect if your mute switch state changes.

Upvotes: 2

Related Questions