-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayermonitor.py
More file actions
32 lines (30 loc) · 790 Bytes
/
playermonitor.py
File metadata and controls
32 lines (30 loc) · 790 Bytes
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
import time
from outputled import OutputLED
class PlayerMonitor:
def __init__(self, player, ledPin):
self.led = OutputLED(int(ledPin))
self.player = player
self.led.off()
self.start()
def start(self):
while True:
try:
status = self.player.status()
if status == "Playing":
if self.led.get_state() != "on":
self.led.on()
elif status == "Paused":
if self.led.get_state() != "blinking":
self.led.blink(0.5)
elif status == "Stopped":
if self.led.get_state() != "off":
self.led.off()
else:
self.led.blink(0.25)
time.sleep(0.5)
#except(dbus.exceptions.DBusException):
# #?won't be necessary when we move all dbus into the player
# self.led.off()
# break
except(KeyboardInterrupt, SystemExit):
raise