Python Forum
I can not play mp3 in pygame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I can not play mp3 in pygame
#1
import pygame
from pygame import mixer
pygame.init()
mixer.init()
mixer.music.load('21.lnk')
mixer.music.play()
Reply
#2
1. Use code tags.

2. show error.

3. is 21.lnk in the same folder ?
99 percent of computer problems exists between chair and keyboard.
Reply
#3
yes, 21.ink in paste
Reply
#4
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')
Recommended Tutorials:
Reply
#5
(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!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020