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()
The problem is it checks for the statement once and so it works if you play it at the exact same time, i want it to be opened, and set an alarm, then play a sound at that time, but after checking the if statement once, it stops.
Aucun commentaire:
Enregistrer un commentaire