我只是为了好玩而编写一个小型 Python 游戏,并且我有一个函数可以开始叙述。
我试图让音频在后台播放,但不幸的是,MP3 文件在功能继续之前先播放。
我如何让它在后台运行?
import playsound
def displayIntro():
playsound.playsound('storm.mp3',True)
print('')
print('')
print_slow('The year is 1845, you have just arrived home...')
另外,有没有办法控制 playsound 模块的音量?
我使用的是 Mac,我并不拘泥于使用 playsound。它似乎是我唯一可以开始工作的模块。
原文由 Nicholas 发布,翻译遵循 CC BY-SA 4.0 许可协议
在 Windows 中:
使用 _winsound.SNDASYNC 异步播放它们:
停止播放
在 Mac 或其他平台上:
你可以试试这个 Pygame/SDL