Python 3.7.2
Pygame 1.9.4
import pygame, sys
Pygame. The init ()
Pygame. Mixer. The init ()
Screen=pygame. Display. Set_mode ([640480])
Pygame, time delay (1000)
Splat=pygame. Mixer. Sound (" 11231. Wav ")
Splat. Play ()
Running=True
While running:
For the event in pygame. Event. The get () :
If the event. The type==pygame. QUIT:
Running=False
Pygame. Quit ()
Use this code can be normal play sound files
import pygame, sys
Pygame. The init ()
Pygame. Mixer. The init ()
Screen=pygame. Display. Set_mode ([640480])
Pygame. Mixer. Music. The load (' tlza. Mp3 ')
Pygame. Mixer. Music. Play ()
Running=True
While running:
For the event in pygame. Event. The get () :
If the event. The type==pygame. QUIT:
Running=False
Pygame. Quit ()
While this period will not be able to play music files
Why is that? How to solve?
Thank you very much!
CodePudding user response:
Pygame. Mixer. Music. Play ()Stop a 10 seconds behind, remember to MP3 is calculated the time problem,
The import time
Time. Sleep (10)
CodePudding user response:
Pygame broadcast voice, a python program is still running, but you can visit pygame is currently playing music, if in, I have been waiting for,
While pygame. Mixer. Get_busy () :
Pass
CodePudding user response:
Mp3 not to come out