python is playing the sound in slowmotion.bitrate of the fle. Below is the code:
import pygame,time
pygame.mixer.init()
pygame.mixer.music.load('backgroundmusic.mp3')
pygame.mixer.music.play(-1)
time.sleep(20)
pygame.mixer.music.stop()
python is playing the sound in slowmotion.bitrate of the fle. Below is the code:
import pygame,time
pygame.mixer.init()
pygame.mixer.music.load('backgroundmusic.mp3')
pygame.mixer.music.play(-1)
time.sleep(20)
pygame.mixer.music.stop()
When you export a sound file to mp3, there is a certain bit rate. This is basically how fast the sound plays. If the bit rate is wrong, the sound plays too fast or too slow. Pygame.mixer is set to play things at the bit rate that will already be default on the program that you save the file on, but if you downloaded the file online this could be difficult. It is best to just set the bitrate to the one of the file using the "size" argument of mixer.init(). However there may be another problem: While pygame.music may support mp3 files, I beleive pygame.mixer is intended for wav files. All this being said, your script doesn't have any issues, but it would be best to save it as a .wav file.