pygame.mixer.music not playing

M.E.Farmer mefjr75 at hotmail.com
Sun Feb 6 09:40:00 EST 2005


Marian Aldenhövel wrote:
> Hi,
>
> I am trying to make pygame play music on windows. This simple
program:
>
> 	import pygame,time
> 	pygame.init()
> 	print "Mixer settings", pygame.mixer.get_init()
> 	print "Mixer channels", pygame.mixer.get_num_channels()
> 	pygame.mixer.music.set_volume(1.0)
> 	pygame.mixer.music.load('file1.mp3)
> 	print "Play"
> 	pygame.mixer.music.play()
>
> 	while pygame.mixer.music.get_busy():
> 		print "Playing", pygame.mixer.music.get_pos()
> 		time.sleep(1)
>
> 	print "Done"
>
> seems to work. It runs the loop and prints values that look like ms
into the
> file. After a reasonable time corresponding to the length of
"file1.mp3" the
> loop is exited and the program ends.
>
> The same thing happens for .mp3 files, .ogg files and .wav files.
>
> Fine. The only problem is that there is no sound :-).
>
> What am I doing wrong? pyGame example games do play sound, but I have
not
> found an example that uses music.
>
> My ultimate goal is to build a MP3 jukebox that runs on Windows and
Linux. I
> have chosen pyGame as I am making a graphical Frontend using OpenGL.
I have
> also tried to look at pymad (which I could not get to work on
Windows, no
> C-Compiler on this machine and I could not find binaries) and audiere
(no
> skipping, at least in the python binding. A feature I would like to
have.)
>
> Ciao, MM
> --
> Marian Aldenhövel, Rosenhain 23, 53123 Bonn. +49 228 624013.
> http://www.marian-aldenhoevel.de
> "Wir brauchen keine Opposition, wir sind bereits Demokraten."

Hello Marian,
First thing out i must tell you that pygame is ok for games but the
music quality is sometimes sketchy, you must set the bit rate to get
good sound quality and there are many other pitfalls. Search the net.
You are not the first to try and build a jukebox out of pygame ;)

Py> import pygame
Py> pygame.mixer.init()
Py> pygame.mixer.music.load('c:/everyday.mp3')
Py> pygame.mixer.play()
Py> pygame.mixer.music.fadeout(4000)

You have a typo in the code you posted that may be your problem.
M.E.Farmer




More information about the Python-list mailing list