【发布时间】:2021-10-11 18:32:53
【问题描述】:
我已经为此工作了好几个小时,并且尝试了从break 中的if 语句到创建索引变量的所有方法。我似乎找不到阻止声音/音乐播放的方法。我的目标是按“Q”并停止函数,然后 while 循环开始另一个 while 循环。
import keyboard
import time
from playsound import playsound
#this handles the name that is displayed and makes it easier to input
def Song(type,opt):
time = 1
print(opt)
playsound(type)
print('''Enter Your Music Selection:
O) Overworld
F) Fighting
B) Boss-Strong Enemy
V) Victory
I) Inside-Taven-Shop
D) Dungion
L) Lose-Death
''')
while True:
while keyboard.is_pressed('O'):
Song('MusicStuff/test0.wav','Overworld Theme')
while keyboard.is_pressed('F'):
Song('MusicStuff/TrashLine.wav','Fighting Theme')
【问题讨论】:
-
这能回答你的问题吗? How to stop audio with playsound module?
标签: python python-3.x python-playsound