File tree Expand file tree Collapse file tree 1 file changed +26
-3
lines changed
Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Original file line number Diff line number Diff line change 1- import datetime
1+ # Requirements : pip install pygame
2+ # Save an audio with the name alarm_clock.mp3
23
3- t = input ("Enter the time in minuts to set Alarm : " )
4- t = datetime .time (0 , int (t ))
4+ from pygame import mixer
5+ import datetime ,time
6+
7+ def musiconloop (file ,stopper ):
8+ mixer .init ()
9+ mixer .music .load (file )
10+ mixer .music .play ()
11+ while True :
12+ input_of_user = input ()
13+ if input_of_user == stopper :
14+ mixer .music .stop ()
15+ break
16+
17+ if __name__ == '__main__' :
18+ t = input ("Enter the time in minutes to set Alarm : " )
19+ secs = int (t )* 60
20+ t = datetime .time (0 , int (t ))
21+ init_t = time .time ()
22+
23+ while True :
24+ if time .time () - init_t > secs :
25+ print ("Enter 'pause' to stop the alarm." )
26+ musiconloop ('alarm_clock.mp3' ,"pause" )
27+ exit ()
You can’t perform that action at this time.
0 commit comments