"Fixed double sound bug"

This commit is contained in:
lieght
2025-10-03 18:34:48 +02:00
parent 796c3a2bc6
commit 56a1afe1cd
2 changed files with 5 additions and 7 deletions

View File

@@ -143,7 +143,7 @@ public final class OptionsMenu extends Menu {
.addPostEvent(AudioEvents.GetCurrentVolume.class)
.onResponse(AudioEvents.GetCurrentVolumeReponse.class, event -> {
volumeSlider.setValue(event.currentVolume() * 100);
}).asyncPostEvent();
}, true).asyncPostEvent();
volumeSlider.setShowTickLabels(true);
volumeSlider.setShowTickMarks(true);
volumeSlider.setMajorTickUnit(25);
@@ -160,11 +160,8 @@ public final class OptionsMenu extends Menu {
if (now - lastPlayed[0] >= cooldown) {
lastPlayed[0] = now;
int value = newVal.intValue();
valueLabel.setText(String.valueOf(value));
new EventFlow().addPostEvent(new AudioEvents.PlayEffect("soft-button-click.wav", false)).asyncPostEvent();
// new EventFlow().addPostEvent(new AudioEvents.clickButton())
// .asyncPostEvent(); // TODO: creates double sound bug, WHYYY????
}
valueLabel.setText(String.valueOf(newVal.intValue()));
new EventFlow().addPostEvent(new AudioEvents.ChangeVolume(newVal.doubleValue()/100.0))

View File

@@ -128,6 +128,7 @@ public class SoundManager {
mediaPlayer.play();
activeMusic.add(mediaPlayer);
logger.info("Playing background music: {}", ma.getFile().getName());
logger.info("Background music next in line: {}", backgroundMusicQueue.peek().getFile().getName());
}
private long playSound(String audioFileName, boolean loop) throws UnsupportedAudioFileException, LineUnavailableException, IOException {
@@ -150,7 +151,7 @@ public class SoundManager {
clip.start();
}
logger.info("Playing sound: {}", asset.getFile().getName());
logger.debug("Playing sound: {}", asset.getFile().getName());
// Generate id for clip
long clipId = idGenerator.nextId();