IOS OpenAL and silent switch

六月ゝ 毕业季﹏ 提交于 2019-12-11 11:51:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!