From d64561da43484ee6ba7493ad13f4b5c00aaba8af Mon Sep 17 00:00:00 2001 From: Georgios Atheridis Date: Sat, 14 Jan 2023 04:35:25 +0000 Subject: [PATCH] random sound test starts new thread --- announcer.pyw | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/announcer.pyw b/announcer.pyw index ce5c761..82c08d9 100644 --- a/announcer.pyw +++ b/announcer.pyw @@ -70,7 +70,8 @@ volume = 100 def play_event_sound(event): ap = audioplayer.AudioPlayer(SOUNDS_FOLDER + random.choice(EVENT_SOUNDS[event])) ap.volume = volume - ap.play(block=True) + ap.play(block=False) + time.sleep(10) def update_volume(v): global volume @@ -81,7 +82,12 @@ def mute(): volume_slider.set(0) def play_random_sound(): - play_event_sound(random.choice(list(EVENT_SOUNDS.keys()))) + sound = random.choice(list(EVENT_SOUNDS.keys())) + threading.Thread( + target=play_event_sound, + args=(sound,), + ).start() + # play_event_sound(random.choice(list(EVENT_SOUNDS.keys()))) def close_script(): gui.quit() @@ -294,4 +300,3 @@ if __name__ == '__main__': announcer_thread = threading.Thread(target=announcer_loop) announcer_thread.start() mainloop() - -- 2.30.2