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

Sound is still played when setting volume despite playSound: false configuration #31

Open
azanli opened this issue May 4, 2018 · 5 comments

Comments

@azanli
Copy link

azanli commented May 4, 2018

When I set the volume to 0 the system vibrates but makes no sound. However when I set the volume back to the initial setting, it plays a sound. Am I interpreting the playSound configuration correctly? It shouldn't be playing a sound when I set the volume back up right?

Here's how I am calling the methods:

  setVolume = (value) => {
    SystemSetting.setVolume(value, {
      type: 'ring',
      playSound: false,
    });
  }

  initializeVolume = () => {
    SystemSetting.getVolume('ring').then((volume)=>{
      this.setVolume(0);
      this.initialVolume = volume;
    });
  }

  componentWillUnmount() {
    this.setVolume(this.initialVolume);
  }

React version: "16.3.0-alpha.1"
React-Native version: "0.54.0"
React-Native-System-Setting: "^1.4.1"
OS: Android 5.1.1

@c19354837
Copy link
Owner

Which android phone are you using?

@azanli
Copy link
Author

azanli commented May 7, 2018

Samsung Galaxy S6 Edge+

It's still giving me the noise. Any ideas?

@c19354837
Copy link
Owner

I'm back.

I've upload a native Android app, download

And the core code looks like:

am.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0); // change volume silently

Slide the progress bar, and tell me the result.

@azanli
Copy link
Author

azanli commented May 14, 2018

This works, it changes the 'Media' volume silently. Shouldn't this hypothetically have the same effect for 'Ring' as well you think?

Does this differ from the existing code:

am.setStreamVolume(volType, (int) (val * am.getStreamMaxVolume(volType)), flags);

where getVolumeType(String type) potentially returns volType == AudioManager.STREAM_MUSIC

Perhaps 'Ring' is the only edge case that doesn't permit a silent setting..? But I can slide the native setting without an auditory feedback. I wonder if it's due to the version of my Android API which is currently 22.

@c19354837
Copy link
Owner

Have you tried this

SystemSetting.setVolume(value, {
      type: 'music',
      playSound: false,
});

Is the same with the test app?

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

No branches or pull requests

2 participants