Playsound 可以同时播放两种声音吗?
Is Playsound able to play two sounds at the same time?
当你按e
时它会播放声音,这很好。但是,当您尝试在声音处于活动状态时按下它时,它会等到声音结束后再播放。我需要同时播放声音。
import tkinter
from playsound import playsound
root = tkinter.Tk()
def key_pressed(event):
playsound('sound.wav')
root.bind("<Key>", key_pressed)
root.mainloop()
试试这个:
import tkinter
from playsound import playsound
root = tkinter.Tk()
def key_pressed(event):
playsound('sound.wav', block=False)
root.bind("<Key>", key_pressed)
root.mainloop()
当你按e
时它会播放声音,这很好。但是,当您尝试在声音处于活动状态时按下它时,它会等到声音结束后再播放。我需要同时播放声音。
import tkinter
from playsound import playsound
root = tkinter.Tk()
def key_pressed(event):
playsound('sound.wav')
root.bind("<Key>", key_pressed)
root.mainloop()
试试这个:
import tkinter
from playsound import playsound
root = tkinter.Tk()
def key_pressed(event):
playsound('sound.wav', block=False)
root.bind("<Key>", key_pressed)
root.mainloop()