question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`addVolumeListener` is fired twice when press volume key

See original GitHub issue

I just tested android device only. There is a problem that the addVolumeListener is called twice when the sound mode is “music”.

my code snipppet is here


  componentDidMount = () => {
    this.volumeListener = SystemSetting.addVolumeListener(this.setVolume);
  };

  componentWillUnmount = () => {
    SystemSetting.removeVolumeListener(this.volumeListener);
  };

  setVolume = currentVolume => {
    console.log("call setvolume");
    this.setState({ currentVolume: currentVolume.value });
  };

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
dreamdev21commented, Mar 18, 2019

Hi. Did anyone solve this issue?

2reactions
MaximeBrlcommented, Dec 13, 2018

This solution does not work for my problem. I start the camera, thanks to a button, a self-timer starts, then after the recording starts. The problem with shouldComponentUpdate is that I don’t care about the rendering of the component. Thanks to the VolumeListener, I want to be able to start recording with the volume button. With a multiple call from the listener, it prevents me from doing what I want and the shouldComponentUpdate() doesn’t work because it only concerns rendering.

Sorry I’m French and I must have made some mistakes.

Edit : I have found a solution but it’s not a good solution

Read more comments on GitHub >

github_iconTop Results From Across the Web

button onClick firing twice - javascript - Stack Overflow
is there a way to prevent this from being called twice or is because I have a input radio tag inside the button...
Read more >
Volume occasionally goes all the way to max/min when I press ...
Sometimes when I press twice on the volume button to adjust the volume up or down it just continues to go all the...
Read more >
Volume buttons changing my screen instead…
Volume buttons changing my screen instead of volume? I recently got a 2013 Macbook Air, but now I'm having a problem. When I...
Read more >
22 Things Your iPhone's Volume Buttons Can Do Besides ...
You can also press and hold a volume button to start recording and let ... disabled for that particular alarm, so double-check its...
Read more >
Next Track: Volume button skip - Apps on Google Play
Next Track lets you skip songs, mute or stop music using your volume buttons. Next Track works with all standard music players to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found