Playing music in Pygame causes an assertion failur

2019-08-23 06:12发布

问题:

I'm having trouble playing music in Pygame. I type:

pygame.mixer.music.load("Maid with the Flaxen Hair.mp3")

pygame.mixer.music.play(-1, 0.0)

but I get this message:

Assertion failed!

Program: C\Python33\pythonw.exe

File:..\..\audio\mpegtoraw.cpp
Line: 505

Expression: audio->rawdatawriteoffset > len

Then it tells me to see C++ documentation. It's not the loading of the music, it's the playing that causes the message. I tried different music files too.

回答1:

Just to update, I had the same error but I tried playing different mp3s and got success with one. I downloaded a sample mp3 from here

So, it seems not all mp3 files are playable.

Hope it helps :)