开发者

iPhone volume changed event for volume already max

I'm using

AudioSessionAddPropertyListener(kAudioSessionProperty_CurrentHardwareOutputVolume, audioVolumeChangeListenerCallback, self);

to detect volume changes so i can take a picture with the volume rockers but if the phone is already at 100% i don't get an event. Is there a way to detect volume rocker pressed when t开发者_C百科he volume doesn't actually change?


I found a good answer with full source code here:

When the user presses the volume buttons in your app, you don’t want the system volume to change. It would suck to have them taking pictures and turn up their ringtone volume all the way or something.

So how do I pull that off? This is pretty hacky but it works.


Well you could set the volume lower after you've registered a volume button press to take a picture. That way the volume never reaches 100% and you can continue getting callbacks. Make sure to lower the volume by more than the volume changes in a single press of the volume button.

You will want to be careful to use some method to prevent receiving multiple notifications at once, but you are likely already doing that if you only take one photo per "button press".

I think I'm going to implement this feature (didn't think it was needed, but now I like the idea) in my app, and I'll post some code if I get it working, let me know if you get yours working as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜