我一直难以让 Sound 对象在我的程序中播放;我没有收到任何错误消息,音频文件本身没有损坏,但是每次我尝试运行我的程序时,我的扬声器都没有声音。我尝试的第一件事是pygame.mixer.Sound.play()
为了播放声音,当我没有听到声音时,我仔细检查以确保我电脑上的扬声器没有静音,我将音量调高,我又试了一次. 我仍然没有听到它在播放,所以我尝试创建一个 Channel 对象并使用以下代码示例告诉程序在该通道上播放声音:
from time import sleep
from pygame import mixer
###
mixer.init() #initialize mixer module
#########
soundObj = mixer.Sound("mySound.wav") #create Sound object from .wav file
soundChn = mixer.Channel(0) #create Channel object to play sounds from
###
soundChn.play(soundObj, 0) #play soundObj on the channel once - ERROR IS HERE
sleep(soundObj.get_length()) #pause program for the duration of soundObj
当我运行我的程序以测试此代码是否有效时,soundChn.play(soundObj, 0)
出现了一个回溯以及错误消息SystemError: Bad call flags in PyCFunction_Call. METH_OLDARGS is no longer supported!
谁能向我解释——请用最简单的英语,因为我很困惑——这个错误消息到底是什么意思,我需要做什么才能解决我的问题?谢谢!