def main(): from playsound import playsound as play import datetime time=datetime.datetime.now() hour=int(input("Hour of alarm: ")) minute=int(input("Minute of alarm: ")) #sound chooser alarm=str(input("Alarm, PI, AC, AV, BE, ZE, IO: ")) noise="" #sound files if alarm== "PI": noise="8D_Pure_Imagination.mp3" elif alarm=="AC": noise="8D_chill2_noise.mp3" elif alarm=="AV": noise="8D_avatar_clip.mp3" elif alarm=="BE": noise="8D_Beach.mp3" elif alarm=="ZE": noise="8D_zelda_clip.mp3" elif alarm=="IO": noise="8D_iroh.mp3" #sound player while 1==1: if time.hour == hour and time.minute == minute: play(noise) else: if time.hour==hour and time.minute== minute: play(noise) main()问题是它检查一次语句,所以如果你在同一时间播放它它就可以工作,我希望它被打开,并设置闹钟,然后在那时播放声音,但在检查一次 if 语句之后,它停止了。
添加回答
举报
0/150
提交
取消