After tagging an audio file with mutagen
pygame no longer seems to be able to play the file. It however loads the file successfully and the call to pygame.mixer.music.play()
throws no error. I actually use the music-tag
library which is just a wrapper around mutagen
for tagging the files. Was wondering if this is known issue.
Code for tagging
import music_tag
f = music_tag.load_file('sample.mp3')
f['title'] = 'Smells like teen spirit'
f['artwork'] = open('nirvana.jpg', 'rb').read()
f.save()
Code for playback
from pygame import mixer
mixer.init()
mixer.music.load('sample.mp3')
mixer.music.set_volume(0.7)
mixer.music.play(-1)
while True:
query = input()
if query == 'q':
mixer.music.stop()
break;
I've also noticed that on removal of the tags, pygame does play the file except the playback is really, really distorted and very different from the actual audio on the file. Meanwhile other mp3 players play the same file with or without tags just fine.
input ()
blocks the entire application until an input is made. Use theKEYDOWN
event to detect when q is pressed (see also Problem when using keyboard commands in pygame):