IOS OpenAL and silent switch

2019-07-25 16:27发布

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条回答
劫难
2楼-- · 2019-07-25 16:37

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];
查看更多
登录 后发表回答