started on now-playing screen

This commit is contained in:
Rudis Muiznieks 2022-12-28 12:26:06 -06:00
parent 2e42703725
commit 7bd634ee31
Signed by: rudism
GPG Key ID: CABF2F86EF7884F9
2 changed files with 11 additions and 5 deletions

View File

@ -26,7 +26,7 @@ def create_directory_menu(directory: str, dirname: str, is_resume: bool):
track_menu.append(MenuItem(fname, MenuType.CMD, {
"dir": directory,
"mode": "single",
"track": path.join(directory, fname)}))
"track": fname}))
if len(dir_menu) > 0:
return MenuItem(dirname, MenuType.SUB_MENU, {"sub_menu": dir_menu})
else:

View File

@ -1,3 +1,4 @@
from os import path
from menu import Menu, MenuType
from cinput import ControlInput
from graphics import Graphics
@ -19,7 +20,7 @@ class MusicPlayer:
elif item.data["mode"] == "random":
self._play_dir(item.data["dir"], True)
elif item.data["mode"] == "single":
self._play_track(item.data["track"])
self._play_track(item.data["dir"], item.data["track"])
elif item.data["mode"] == "resume":
self._play_resume(item.data["dir"])
elif item.menu_type == MenuType.BACK:
@ -29,13 +30,18 @@ class MusicPlayer:
ic("Playing", directory, random)
return
def _play_track(self, track: str):
def _play_track(self, directory: str, track: str):
ic("Playing", track)
self._draw_now_playing(track)
player = MPV()
player.play(track)
player.wait_for_playback()
player.play(path.join(directory, track))
return
def _play_resume(self, directory: str):
ic("Resuming", directory)
return
def _draw_now_playing(self, track_name: str):
self._graphics.clear()
self._graphics.rect(0, 0, 128, 64, 1)
self._graphics.text(track_name, 2, 2, 1)