Boost audio volume more than 100% in react native

Viewed 1183

My app is music player and some of the mp3's have lower volume. I want to Boost audio volume more than 100% in react native.

I have to tried this plugin:

  • react-native-volume-control
  • react-native-system-setting
  • react-native-audio-manager
  • react-native-sound
2 Answers

No, It's not possible, You have to increase the volume of the file that is playing like for example the vlc player does when you increase the volume beyond 100%. It has nothing to do with the volume you set to the phone, it just compensates for files which have a more quiet audio track.

You can try Web Audio API

function amplifyMedia(mediaElem, multiplier) {
  var context = new (window.AudioContext || window.webkitAudioContext),
      result = {
        context: context,
        source: context.createMediaElementSource(mediaElem),
        gain: context.createGain(),
        media: mediaElem,
        amplify: function(multiplier) { result.gain.gain.value = multiplier; },
        getAmpLevel: function() { return result.gain.gain.value; }
      };
  result.source.connect(result.gain);
  result.gain.connect(context.destination);
  result.amplify(multiplier);
  return result;
}

You may need to implement a Native Module yourself for js to call setStereoVolume() on your AudioTrack if you are using AudioTrack.Or if you are using ExoPlayer to play music,try implement a custom AudioProcessor to copy each channel and apply the amplification.

Related