From 720258441ba97e2caf855abcfbe180573d5671c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=ADdac=20Sabat=C3=A9s?= Date: Thu, 25 Apr 2019 12:02:12 +0200 Subject: [PATCH] refractor player --- lib/player.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/player.py b/lib/player.py index c7c8f43..a053904 100644 --- a/lib/player.py +++ b/lib/player.py @@ -4,12 +4,10 @@ def play(pin): - # Start pygame mixer + # Start pygame mixer if it's not running if not mixer.get_init(): - print("Starting mixer") mixer.init() else: - print("Mixer alredy enabled") if not mixer.music.get_busy() == True: # Users pygame mixer to load an mp3 file and play it @@ -21,17 +19,12 @@ def play(pin): if exists: mixer.music.load(filename) else: + # We load the not found file if the file doesn't exist mixer.music.load('./voice_files/not_found.mp3') + # Play the audio file mixer.music.play() - # Checks if it's busy playing the sound - # while mixer.music.get_busy() == True: - # continue - - # Close mixer - # mixer.quit() - if __name__ == '__main__': play(sys.argv[1])