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()