python3+pygame播放声音

来源:互联网 发布:优化关键词密度的方法 编辑:程序博客网 时间:2024/06/05 23:46
python3+pygame播放声音,折腾了好久播放不出声音,找不到原因,后来发现,pygame对MP3格式有严格要求,支持不如ogg格式好,并且需要加上这一句【screen=pygame.display.set_mode([640,480])】才能正常播放,不清楚具体原因,如果注释了则无声音import pygame,sysfilename='ll.ogg'pygame.init()pygame.mixer.init()screen=pygame.display.set_mode([480,320])  #注意这一句pygame.time.delay(1000)pygame.mixer.music.load(filename)pygame.mixer.music.play()while 1:    for event in pygame.event.get():        if event.type==pygame.QUIT:            sys.exit()
原创粉丝点击