CipherBitCorp / VolumeButtonHandler

VolumeButtonHandler for iOS
Apache License 2.0
14 stars 2 forks source link

Error when volume is maxed out #3

Open Joao-Neves opened 7 months ago

Joao-Neves commented 7 months ago

When I open the app that I'm developing that uses this library there seems to be an error. Sometimes when I press the Volume Up button the downBlock gets called and sometimes I get 2 blocks called in a row with just one button press.

This is with iPhone 11 and iOS 17.4

kaanselhep commented 7 months ago

Hey @Joao-Neves thanks for logging this. I wasn't able to reproduce this during my testing. I've made tiny changes in the code that I feel would be improvements and perhaps will fix what you're experiencing. If it doesn't, would you mind explaining a bit more in detail exactly how it occurs? Are you pressing the up/down buttons really fast? When the issue occurs, does the volume actually change or does it stay the same? Are you seeing the volume view (white bar) to the left of the screen when you use it?

kaanselhep commented 7 months ago

@Joao-Neves the latest version is 1.1.1 if you'd like to try it out

Joao-Neves commented 7 months ago

Hey @kaanselhep. Thank you for the quick reply. I put it in the title but I forgot to explain in the body. This only happens if I have the volume at maximum (1.0) before I start using the app that uses this lib.

I'll test the latest version and I'll come back to you to see if the issue has been fixed or not.

Joao-Neves commented 7 months ago

@kaanselhep With the current changes I no longer get duplicated or wrong calls but as soon as the volume hits the maximum the upBlock stops being called. It doesn't matter if the volume starts at maximum or if it gets there while after pressing the Volume Up button enough times.

I hope this helps!

kaanselhep commented 7 months ago

Hi @Joao-Neves ,

Ok understood! This is by design but I think it'd be nice to have a callback in this case you're mentioning too.

I'll make another release tonight and it'll have 2 styles of callbacks:

  1. volumeIncreased & volumeDecreased
  2. upBlock & downBlock

Volume increased will only be called when volume actually increases. And similar idea for volume decrease

But the upBlock and downBlock will always be called upon pressing the up/down buttons (even if volume is at max or min).

How does that sound? It should solve your issue 😃

Cheers!

Joao-Neves commented 7 months ago

@kaanselhep That sounds great! That's exactly what I need thank you 🙇.

I've just tested version 1.1.1 and it seems that it still has the same issue with the upBlock not being called when the volume reaches the maximum value. I also can't find the volumeIncreased & volumeDecreased callbacks. Perhaps there was some change that wasn't commited?

kaanselhep commented 7 months ago

Hi @Joao-Neves Sorry didn't have time yesterday so didn't make those changes yet but will ping you once I do. Should be quick and easy. Released with 1.1.2

kaanselhep commented 7 months ago

Hi @Joao-Neves , Actually maybe I was wrong. I looked into implementing what's needed and it seems it's more difficult than we thought. Because the library works by checking the outputVolume and attaching an observer to its changes, we are able to capture a Up/Down volume rocker tap but because the outputVolume doesn't actually change when it's at max or min volume, the observer isn't getting notified and as a result we don't know if the user tapped the up/down button.