问题
I'm using 4.3.2 IOS and OpenAL and it seems that it doesn't care about the silent switch. (while it was working nicely with previous IOS versions)
Also the trick using AudioSessionGetProperty to 'read' the switch status is not working anymore. Thus I can't even mute using code.
Any hint, news about it recently?
回答1:
You can still use programmatic approaches to get the mute switch state, however there's one thing you need to be sure about:
set your AVAudioSession to Ambient! If you set it to Playback for example, that will not care about the mute switch state!
You can simply set the state like this:
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
To find some code examples for querying the mute switch state from within your app, you can find working samples here.
I had the same issue as you had when I was using Finch for OpenAL. I just set the soundengine to initiate an Ambient session and now my mute switch works properly:
[soundEngine activateAudioSessionWithCategory:AVAudioSessionCategoryAmbient];
来源:https://stackoverflow.com/questions/6340221/ios-openal-and-silent-switch