0

I have a pwa built with react and have gotten twa .apk from it using the pwabuilder.com, having a mute video playing on my screen, I want to unmute the video when the user presses the volume change buttons of the android mobile device,

is there a way to detect this? (without using other technologies like react-native or ionic etc)

moeinghasemi
  • 81
  • 1
  • 10

1 Answers1

0

Try this, but will depend on the device and browser used Implementing the volumechange listener

window.addEventListener('volumechange', function() {
  // Get the current volume level
  var volume = Math.round((window.volume * 100));

  // Check if the volume has increased or decreased
  if (window.lastVolume > window.volume) {
    // Volume has decreased
    
  } else if (window.lastVolume < window.volume) {
    // Volume has increased
    
  }

  // Update the last volume value
  window.lastVolume = window.volume;
});

// Initialize the last volume value
window.lastVolume = window.volume;
Ingenious_Hans
  • 724
  • 5
  • 16