I picked up a pirate radio from the PiParty and i’m trying to make a pygame mixer music player, however i’m currently not getting a sound output.
When running the following code:
from pygame import mixer import phatbeat volume = 0.5 state = 'pause' mixer.init() mixer.music.load('test.mp3') @phatbeat.on(phatbeat.BTN_PLAYPAUSE) def play_pause(pin): global state print "play" if state == 'pause': mixer.music.play() state = 'play' if state == 'play': mixer.music.pause() state = 'pause' while True: pass
I get the following output:
When just opening python, if i type in the following commands, the music plays, and i receive no ALSA messages.
from pygame import mixer mixer.init() mixer.music.load('test.mp3') mixer.music.play()
I’m not going to lie, I am not too good at coding, so it could very well be an issue with the code, however the “ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred” error is really confusing me!