import pygame
pygame.mixer.init()
pygame.mixer.music.load("only one.mp3")
pygame.mixer.music.play(0)
while pygame.mixer.music.get_busy():
pygame.time.Clock().tick(10)
When I run the code, there's no sound and the program ends in like a second. Initially I didn't have the while loop until I saw the suggestions in the answers to similar questions. The program does enter the while loop on my friend's windows system, but not on my mac, and it doesn't have any sound either even on my friend's windows system. Does anybody know how to solve it?
Pygame sound not working fix
INFO
Note:
The code is the same as yours but i just replaced it with my music file to check it.
You can see it in the image :
In this image
.wav files seem to work well
You can download pydub from this
Or type this command in the command line:
it would be easier if u changed the mp3 to ogg format ,try this.. its simple
vote the answer if its working, if not tell me whats wrong
This works fine with Windows 8 and Python 2.7.6 and *.wav files
The different flags you can check if you type
winsound.
and look for the autofill list.The flags are like
SND_FILENAME
or similar.If you type them into the editor like:
*winsound.SND_FILENAME
you get the integer to apply in thePLaySound
command from aboveHave fun
Works well on Ubuntu 10.04 and Pygame 1.9.1.
Some things you can try:
pygame.init()
pygame.display.set_mode((200,100))
pygame.event.get()
Example: