Python Forum

Full Version: I can not play mp3 in pygame
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
import pygame
from pygame import mixer
pygame.init()
mixer.init()
mixer.music.load('21.lnk')
mixer.music.play()
1. Use code tags.

2. show error.

3. is 21.lnk in the same folder ?
yes, 21.ink in paste
you need a main game loop to keep the script from reaching the end of the program.

add all this after your code in the first post
done = False
song_ended = pygame.USEREVENT + 1
while not done:
    for event in pygame.event.get():
        if event.type == song_ended:
            print('The song ended')
(Feb-09-2018, 05:13 AM)metulburr Wrote: [ -> ]you need a main game loop to keep the script from reaching the end of the program.

add all this after your code in the first post
done = False
song_ended = pygame.USEREVENT + 1
while not done:
    for event in pygame.event.get():
        if event.type == song_ended:
            print('The song ended')

Super useful, thanks!