Skip to content

Commit b03c465

Browse files
authored
Merge pull request #6 from JanviRaina/janvir
Added Alarm Clock Python Program
2 parents 3dccc00 + 605bd53 commit b03c465

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

Final Capstone Project/Alarm_clock.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
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()

0 commit comments

Comments
 (0)