Skip to content Skip to sidebar Skip to footer

Can't Hear The Sounds I Am Tring To Play With Pygame

I can't hear the sounds I am trying to play with pygame. This is my code. import pygame pygame.init() pygame.mixer.music.load(r'C:\Users\Isaiah\Desktop\easy_going.mp3') pygame.m

Solution 1:

MP3 support is limited with Pygame; use .wav instead. Fortunately you can easily convert .mp3 files to .wav files with an online conversions tool.

You also need to add a delay loop at the end to keep your program from closing prematurely.

Convert your .mp3 to a .wav and then try running this modified code.

import pygame

#Replaced init() with mixer.init() 
pygame.mixer.init()

sound = pygame.mixer.Sound(r"C:\Users\Isaiah\Desktop\easy_going.wav")
s = pygame.mixer.Sound.play(sound)

#Delay loopwhile s.get_busy():
    pygame.time.delay(100)

Good luck!

Post a Comment for "Can't Hear The Sounds I Am Tring To Play With Pygame"