jpsim / JPSVolumeButtonHandler

JPSVolumeButtonHandler provides an easy block interface to hardware volume buttons on iOS devices. Perfect for camera apps!
MIT License
336 stars 91 forks source link

Event issue at initialization #43

Open ghost opened 7 years ago

ghost commented 7 years ago

Thanks for this awesome library. I'm facing an issue, at initialization, PSVolumeButtonHandler adjusts the volume to avoid a maximum or minimum state (i suppose that in this state, it will couldn't detect any event on volume buttons). But when adjusting, it's triggering by itself and call the upBlock or downBlock.

how to avoid that ?

jpsim commented 7 years ago

That shouldn't happen. Maybe someone more actively involved in this library than I would be able to make a repro case?

apple-ihack-geek commented 7 years ago

We are seeing this in our app currently using 1.0.2, I'm going to retry with latest master

jasongaare commented 7 years ago

I'm seeing this issue also.

jpsim commented 7 years ago

@titiSbr @apple-ihack-geek @jasongaare I assume you're all seeing this with 1.0.4 too? There's an unfortunate lack of information or repro cases in this thread 😞

apple-ihack-geek commented 7 years ago

After further review, My issue was slightly different. Mine was not at initialization, mine was an event issue by another event (an infinitient loop of volume presses). Sadly, I had to pull the button handler our entirely due to another issue I'm not sure how to resolve, https://github.com/jpsim/JPSVolumeButtonHandler/issues/46

apple-ihack-geek commented 7 years ago

For other people still experiencing this, you can try the new exactJumpsOnly feature https://github.com/jpsim/JPSVolumeButtonHandler/pull/45

jpeyer commented 7 years ago

The exact jumps feature worked for me, but caused a different issue where the min/max logic no longer works.

I think the problem is that -[JPSVolumeButtonHandler startHandler:] is calling setupSession too early (in addition to calling it twice). The first call should not be there, and it causes the delayed second call to do nothing, because isStarted is set to true the first time setupSession is called). After I removed that line, I haven't seen the issue.

xaphod commented 7 years ago

I'm seeing this too. With JPSVBH included, about 75% of the time when I start my app I see the volume level displayed and then the up handler fires. The volume level never displays if I take out JPSVBH

genericwoods commented 7 years ago

This is happening for me as well. exactJumpsOnly avoids this issue, but also stops the handler from firing at all for min/max volumes

apple-ihack-geek commented 7 years ago

@genericwoods Are you sure you're using the latest version? The not firing at max/min was an bug (of my own doing) but was fixed with https://github.com/jpsim/JPSVolumeButtonHandler/pull/47 (or so I think).

genericwoods commented 7 years ago

@apple-ihack-geek we’re using 1.0.4 via Cocoapods – is #47 included in that release?

Edit: Nevermind, noticed on the issue that it was never tagged for release, moved the conversation over there

apple-ihack-geek commented 7 years ago

@genericwoods no, it hasn't had a release tag yet. For now, you should be able to manually set it to commit id 08850cf30a3d823bc29f917685653e0029616bdf. Give that a try.