Skip to content

Commit

Permalink
refractor player
Browse files Browse the repository at this point in the history
  • Loading branch information
sabatesduran committed Apr 25, 2019
1 parent 80229bf commit 7202584
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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])

0 comments on commit 7202584

Please sign in to comment.