python3+pygame播放声音,折腾了好久播放不出声音,找不到原因,后来发现,pygame对MP3格式有严格要求,支持不如ogg格式好,并且需要加上这一句【 screen=pygame.display.set_mode([640,480])】才能正常播放,不清楚具体原因,如果注释了则无声音 import pygame,sys filename='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()
python3+pygame播放声音
最新推荐文章于 2025-02-27 16:06:56 发布