Semplifica la gestione audio rimuovendo il supporto per più dispositivi e centralizzando l'uso di un singolo dispositivo audio

This commit is contained in:
2024-12-26 01:14:26 +01:00
parent 3e7056e23f
commit ccf7769979
2 changed files with 10 additions and 16 deletions
+4
View File
@@ -142,12 +142,16 @@ class MiceMaze(controls.KeyBindings):
self.engine.scroll_view(self.pointer)
def play_sound(self, sound_file,tag="main"):
self.engine.play_sound(sound_file)
return
if self.audio:
if len(self.sounds) > 5:
self.sounds.pop(next(iter(self.sounds))).kill()
self.sounds[f"{tag}_{random.random()}"] = subprocess.Popen(["aplay", f"sound/{sound_file}"])
def stop_sound(self, tag=None):
self.engine.stop_sound()
return
for key, value in self.sounds.copy().items():
if tag is None or tag in key:
value.kill()