|
@@ -55,7 +55,7 @@ class Musikautomat:
|
|
(r"/(.*)", tornado.web.StaticFileHandler, {"path" : "./web",
|
|
(r"/(.*)", tornado.web.StaticFileHandler, {"path" : "./web",
|
|
"default_filename" : "index.html" }),
|
|
"default_filename" : "index.html" }),
|
|
]
|
|
]
|
|
-
|
|
|
|
|
|
+
|
|
asyncio.set_event_loop(asyncio.new_event_loop())
|
|
asyncio.set_event_loop(asyncio.new_event_loop())
|
|
app = tornado.web.Application(urls, debug=False)
|
|
app = tornado.web.Application(urls, debug=False)
|
|
app.listen(8080)
|
|
app.listen(8080)
|
|
@@ -73,13 +73,13 @@ class Musikautomat:
|
|
try:
|
|
try:
|
|
|
|
|
|
for event in pygame.event.get():
|
|
for event in pygame.event.get():
|
|
-
|
|
|
|
|
|
+
|
|
# Handle exit event
|
|
# Handle exit event
|
|
-
|
|
|
|
|
|
+
|
|
if event.type == pygame.QUIT:
|
|
if event.type == pygame.QUIT:
|
|
pygame.quit()
|
|
pygame.quit()
|
|
sys.exit()
|
|
sys.exit()
|
|
-
|
|
|
|
|
|
+
|
|
# Handle key events
|
|
# Handle key events
|
|
|
|
|
|
if event.type == pygame.KEYDOWN:
|
|
if event.type == pygame.KEYDOWN:
|
|
@@ -93,7 +93,7 @@ class Musikautomat:
|
|
elif event.key == pygame.K_RIGHT:
|
|
elif event.key == pygame.K_RIGHT:
|
|
|
|
|
|
if self._eventSink == self._player:
|
|
if self._eventSink == self._player:
|
|
- self._player.togglePlay()
|
|
|
|
|
|
+ self._player.togglePlay()
|
|
else:
|
|
else:
|
|
self.play(self._display.currentItem())
|
|
self.play(self._display.currentItem())
|
|
|
|
|
|
@@ -105,19 +105,19 @@ class Musikautomat:
|
|
self._display.update()
|
|
self._display.update()
|
|
|
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
-
|
|
|
|
|
|
+
|
|
# Display error
|
|
# Display error
|
|
traceback.print_exc()
|
|
traceback.print_exc()
|
|
|
|
|
|
self._pydsp.fill((0,0,0))
|
|
self._pydsp.fill((0,0,0))
|
|
font = pygame.font.Font('freesansbold.ttf', 12)
|
|
font = pygame.font.Font('freesansbold.ttf', 12)
|
|
-
|
|
|
|
|
|
+
|
|
s = str(e)
|
|
s = str(e)
|
|
n = int(self._dx / 6)
|
|
n = int(self._dx / 6)
|
|
for i, start in enumerate(range(0, len(s), n)):
|
|
for i, start in enumerate(range(0, len(s), n)):
|
|
text = font.render(s[start:start+n], True, (255, 0, 0) , (0, 0, 0))
|
|
text = font.render(s[start:start+n], True, (255, 0, 0) , (0, 0, 0))
|
|
self._pydsp.blit(text, (0, i * 12))
|
|
self._pydsp.blit(text, (0, i * 12))
|
|
-
|
|
|
|
|
|
+
|
|
self._eventSink = self._display
|
|
self._eventSink = self._display
|
|
|
|
|
|
pygame.display.update()
|
|
pygame.display.update()
|
|
@@ -138,7 +138,7 @@ class Musikautomat:
|
|
raise Exception("Unknown type: %s" % t)
|
|
raise Exception("Unknown type: %s" % t)
|
|
|
|
|
|
if start:
|
|
if start:
|
|
- self._player.togglePlay()
|
|
|
|
|
|
+ self._player.togglePlay()
|
|
|
|
|
|
|
|
|
|
def playDir(self, item):
|
|
def playDir(self, item):
|
|
@@ -148,7 +148,7 @@ class Musikautomat:
|
|
path = item.get("path")
|
|
path = item.get("path")
|
|
files = os.listdir(path)
|
|
files = os.listdir(path)
|
|
|
|
|
|
- self._player.setPlaylist(sorted([{
|
|
|
|
|
|
+ self._player.setPlaylist(sorted([{
|
|
"name" : f,
|
|
"name" : f,
|
|
"path" : os.path.join(path, f)
|
|
"path" : os.path.join(path, f)
|
|
} for f in files], key=lambda i: i["name"]))
|
|
} for f in files], key=lambda i: i["name"]))
|