CipherBitCorp / VolumeButtonHandler

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

Some clicks can be missed #4

Open TkachenkoViacheslav opened 2 months ago

TkachenkoViacheslav commented 2 months ago

Steps to reproduce (it's hard and not always reproducible): 1) disableSystemVolumeHandler = true 2) with a delay about 1-2 seconds click "up" -> "down" -> "up" -> "down" -> ... 3) On some time, pressing on the up/down button won't result in firing blocks, In code inside "public override func observeValue(...)" we are getting into the next If block:

if disableSystemVolumeHandler && newVolume == Float(initialVolume) {
                // Resetting volume, skip blocks
                we are here!
                return
} else { ... 

but in fact button press was detected and newVolume != oldValue

TkachenkoViacheslav commented 2 months ago

Solution: 1) the condition above should be changed to the:

if disableSystemVolumeHandler && newVolume == oldVolume {
                // Resetting volume, skip blocks
                return
} else { ... 

2) at the end of function "public override func observeValue(...)" the "Reset volume method" should be wrapped in an If statement:

// Reset volume
if newVolume != Float(initialVolume) {
            setSystemVolume(initialVolume)
}
TkachenkoViacheslav commented 2 months ago

I'm sorry, my solution is wrong. But the bug is actual