Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

detect the "up" volume button on the device when is in the highest level

I'm trying to detect the "up volume" button on the device and run a method.

The next code works fine detecting the changes of the volume level, but when I'm on the highest level the selector isn't called (because the in the volume level doesn't occur any change)

 AVAudioSession* audioSession = [AVAudioSession sharedInstance];
    [audioSession setActive:YES error:nil];
    [audioSession addObserver:self
                   forKeyPath:@"outputVolume"
                      options:0
                      context:nil];

Is there any workaround that I can do to detect the "up volume" button when the device has de highest level of volume?

Thanks

like image 562
Sergio Magoo Quintero Avatar asked Nov 22 '25 08:11

Sergio Magoo Quintero


1 Answers

When the user changes the volume to the highest setting, instead of setting it to max, set it to MAX - some small amount. Then the callback will always be called because the volume can never be truly maxed out.

like image 120
Bergasms Avatar answered Nov 25 '25 00:11

Bergasms



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!