-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path__init__.py
More file actions
109 lines (99 loc) · 3.27 KB
/
__init__.py
File metadata and controls
109 lines (99 loc) · 3.27 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import controls
import pygame
done = False
inter = controls.interface()
inter.musicController()
menu = controls.menu
sensitivity = 200
lastPress = {
"up": 0,
"down": 0,
"left": 0,
"right": 0,
"select": 0
}
while not done:
inter.loop()
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
if event.type == pygame.KEYDOWN:
print(pygame.time.get_ticks())
if event.key == pygame.K_UP:
ticks = pygame.time.get_ticks()
if inter.sleep:
inter.volumeUp()
else:
inter.menuAction("up")
lastPress["up"] = ticks
elif event.key == pygame.K_DOWN:
ticks = pygame.time.get_ticks()
if inter.sleep:
inter.volumeDown()
else:
inter.menuAction("down")
lastPress["down"] = ticks
elif event.key == pygame.K_LEFT:
ticks = pygame.time.get_ticks()
if inter.sleep:
inter.prev()
else:
inter.menuAction("left")
lastPress["left"] = ticks
elif event.key == pygame.K_RIGHT:
ticks = pygame.time.get_ticks()
if inter.sleep:
inter.next()
else:
inter.menuAction("right")
lastPress["right"] = ticks
elif event.key == pygame.K_RETURN:
ticks = pygame.time.get_ticks()
if inter.sleep:
if ticks-lastPress["select"] < sensitivity:
inter.toggleSleep()
inter.playPause()
else:
inter.playPause()
elif menu["current"] == "list" or menu["current"] == "Tracks":
inter.play(menu[menu["current"]][inter.selectedItem]) # Play the selected song
if menu["Queue"]:
for item in list(menu[menu["current"]]):
if item not in menu["Queue"]:
menu["Queue"].append(item)
else:
menu["Queue"] = list(menu[menu["current"]]) # copy the list where the song is selected to the queue
menu["Queue"].remove(menu[menu["current"]][inter.selectedItem]) # Remove selected
menu["Queue"].insert(0, menu[menu["current"]][inter.selectedItem]) # Put selected at first position
elif menu["current"] == "musicController":
if inter.selectedItem == 0:
inter.volumeUp()
elif inter.selectedItem == 1:
inter.volumeDown()
elif inter.selectedItem == 2:
inter.prev()
elif inter.selectedItem == 3:
inter.playPause()
elif inter.selectedItem == 4:
inter.next()
elif inter.selectedItem == 5:
inter.shuffle()
elif inter.selectedItem == 6:
inter.clearQueue()
else:
inter.menuAction("select")
lastPress["select"] = ticks
if not inter.sleep :
# [filename, artist, album, title]
if menu["current"] == "musicController":
inter.musicController()
elif menu["current"] == "Tracks" or menu["current"] == "Queue":
inter.listView(list(map(lambda x: x[3], menu[menu["current"]])))
elif menu["current"] == "list":
inter.listView(list(map(lambda x: x[3], menu["list"])))
else:
inter.listView(menu[menu["current"]])
if pygame.time.get_ticks()-max(lastPress.values()) >= 10000:
inter.toggleSleep()
pygame.display.update() # display.update() without arguments updates the entire display just like display.flip()
pygame.time.Clock().tick(20) # Limit the framerate to 20 FPS, this is to ensure it doesn't use all of the CPU resources