Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panning for Android #70

Open
sepans opened this issue Sep 28, 2016 · 0 comments
Open

Panning for Android #70

sepans opened this issue Sep 28, 2016 · 0 comments

Comments

@sepans
Copy link

sepans commented Sep 28, 2016

I did a simple implementation of panning for Android by modifying setVolume and setPan in sound.js. I don't know if it is the right way for doing it but documenting it here in case it is useful:

Sound.prototype.setVolume = function(value) {
  this._volume = value;
  if (this._loaded) {
    if (IsAndroid) {
      var leftVolume = value < 0 ? this._volume * (1 - Math.abs(value)) : this._volume;
      var rightVolume = value > 0 ? this._volume * (1 - value) : this._volume;
      RNSound.setVolume(this._key, leftVolume, rightVolume);
    } else {
      RNSound.setVolume(this._key, value);
    }
  }
  return this;
};

Sound.prototype.setPan = function(value) {
  if (this._loaded) {
    if (IsAndroid) {
      var leftVolume = value < 0 ? this._volume * (1 - Math.abs(value)) : this._volume;
      var rightVolume = value > 0 ? this._volume * (1 - value) : this._volume;
      this._pan = value; //should this be outside of if(this._loaded)like setVolume?
      RNSound.setVolume(this._key, leftVolume, rightVolume);
    } else {
      RNSound.setPan(this._key, this._pan = value);  
    }
  }
  return this;

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants