0

I have a problem with playing sounds using libgdx on android device.

At the first time it works but not with full volume then the volume becomes higher. Although it works fine at desktop project.

Here is my code:

Assets class

public class Assets {

    public final AssetManager manager = new AssetManager();
    public final String btn = "sfx/button.ogg";

    public void load() {
        manager.load(btn, Sound.class);
        manager.finishLoading();
    }

    public Sound getSound(String name) {
        return manager.get(name, Sound.class);
    }
}

SoundEffects class

public class SoundEffects {

    Assets assets;

    public SoundEffects(Assets assets) {
        this.assets = assets;
    }

    public void btn() {
        assets.getSound(assets.btn).play(1.0f);
    }
}

Then whenever I use code I just call soundEffects.btn()

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
MAGS94
  • 500
  • 4
  • 15
  • In my app (game) I'm playing some sound immediately after app starts and it's played well on desktop, but it doesn't play at all on android. All sounds after that are played well. Must be that phone sound system is not so perfect - it takes time to start working. – MilanG Jan 25 '18 at 07:28

1 Answers1

0

Since it works fine on the desktop project version it is probably just the wrapper of libgdx inside Android that takes some time to adjust to the changed volume.

There is a similar thread - How to maximize volume in an Android App that might give you a better idea on how to manipulate the Android volume controls.