#该代码可实现制定时间段音乐播放
# pip install pygame
import pygame,sys
pygame.init()
pygame.mixer.init()
screen=pygame.display.set_mode([640,480])
pygame.time.delay(1000)
pygame.mixer.music.load("filename.mp3")
pygame.mixer.music.play()
soundwav=pygame.mixer.Sound("filename.wav")
while 1:
for event in pygame.event.get():
if event.type==pygame.QUIT:
sys.exit()
if not pygame.mixer.music.get_busy():
soundwav.play()
pygame.time.delay(5000)#等待5秒让filename.wav播放结束
sys.exit()