-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise 7.py
More file actions
93 lines (72 loc) · 2.51 KB
/
exercise 7.py
File metadata and controls
93 lines (72 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from pygame import mixer
import time
import datetime
def musiconloop(file, stopper):
mixer.init()
mixer.music.load(file)
# mixer.music.set_volume(0.7)
while True:
mixer.music.play()
user_input = input("Enter The Stopper:\n")
if user_input==stopper:
mixer.music.stop()
break
def log(msg):
with open("records.txt", "a") as f:
f.write(f"{msg} is done at {datetime.datetime.now()}\n")
watersces = 5
eyessces = 15
physces = 25
if __name__ == "__main__":
init_water = time.time()
init_eyes = time.time()
init_physical = time.time()
# for water
while True:
if (time.time()-init_water)>watersces:
# time.sleep(5)
print("Water Reminder, Type 'drank' to stop the sound")
musiconloop(r"E:\NITESH\Study\Python\Part 2\Asserts\Sound Effects\water.mp3", "drank")
init_water = time.time()
log("Water drink task")
# for eyes exercise
if (time.time()-init_eyes)>eyessces:
# time.sleep(5)
print("Eyes Reminder, Type 'Eydone' to stop the sound")
musiconloop(r"E:\NITESH\Study\Python\Part 2\Asserts\Sound Effects\eyes.mp3", "Eydone")
init_eyes = time.time()
log("Eyes exercise task")
# for physical exercise
if (time.time()-init_physical)>physces:
# time.sleep(5)
print("Phical Exercise Reminder, Type 'Eydone' to stop the sound")
musiconloop(r"E:\NITESH\Study\Python\Part 2\Asserts\Sound Effects\physical.mp3", "Phydone")
init_physical = time.time()
log("Physical exercise task")
# # Modules
# import pygame
# from datetime import datetime
# import time
# # sound player
# def water():
# pygame.mixer.init()
# pygame.mixer.music.load(r"E:\NITESH\Study\Python\Part 2\Asserts\Sound Effects\water.mp3")
# pygame.mixer.music.set_volume(0.7)
# pygame.mixer.music.play()
# while pygame.mixer.music.get_busy():
# pygame.time.Clock().tick(10)
# # Time
# # now = datetime.now()
# # current_time = now.strftime("%H:%M:%S")
# # hour, minute, seconds = current_time.split(":")
# # # Main Program
# # print(f"Current Time: {current_time}")
# # game = True
# # while int(hour)>9 and int(hour)<23:
# # time.sleep(3)
# # while game:
# # water()
# # query = input("Did you drank water:\n")
# # if "drank" in query:
# # print("We will notify you after 10s")
# # time.sleep(10)