pygame的,声音不玩 [英] Pygame, sounds don't play
问题描述
我试图与pygame的播放声音文件(.WAV),但是当我开始它,我从来没有听到任何声音。结果
这是code:
I'm trying to play sound files (.wav) with pygame but when I start it I never hear anything.
This is the code:
import pygame
pygame.init()
pygame.mixer.init()
sounda= pygame.mixer.Sound("desert_rustle.wav")
sounda.play()
我也使用渠道尝试,但结果是一样的。
I also tried using channels but the result is the same
推荐答案
您code剧 desert_rustle.wav
我的机器上相当精细(的Mac OSX 10.5,巨蟒2.6.4,1.9.1 Pygame的)。什么操作系统和Python和pygame的版本是您使用?你能听到 .WAV
通过其他方式确定(例如:打开
在Mac上的终端或启动
Windows控制台后的文件名/路径 .WAV
文件),以保函文件上没有损坏?这很难不能够重现它,也不必所有这些关键的细节来调试您的具体问题(这是不是与code你给)。
Your code plays desert_rustle.wav
quite fine on my machine (Mac OSX 10.5, Python 2.6.4, pygame 1.9.1). What OS and Python and pygame releases are you using? Can you hear the .wav
OK by other means (e.g. open
on a Mac's terminal or start
on a Windows console followed by the filename/path to the .wav
file) to guarante the file is not damaged? It's hard to debug your specific problem (which is not with the code you give) without being able to reproduce it and without having all of these crucial details.
这篇关于pygame的,声音不玩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!