From 7bd634ee31d9c7d8e51e55cff35e1ca5d9d369af Mon Sep 17 00:00:00 2001 From: Rudis Muiznieks Date: Wed, 28 Dec 2022 12:26:06 -0600 Subject: [PATCH] started on now-playing screen --- plugin/music/__init__.py | 2 +- plugin/music/player.py | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/plugin/music/__init__.py b/plugin/music/__init__.py index c3b3c0d..7a12775 100644 --- a/plugin/music/__init__.py +++ b/plugin/music/__init__.py @@ -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: diff --git a/plugin/music/player.py b/plugin/music/player.py index a844596..bac35b8 100644 --- a/plugin/music/player.py +++ b/plugin/music/player.py @@ -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)