from menu import Menu, MenuType from cinput import ControlInput from graphics import Graphics from icecream import ic from mpv import MPV class MusicPlayer: def __init__(self, cinput: ControlInput, graphics: Graphics, menu: Menu): self._cinput = cinput self._graphics = graphics self._menu = menu def run(self): while True: item = self._menu.get_selection() if item.menu_type == MenuType.CMD: if item.data["mode"] == "album": self._play_dir(item.data["dir"], False) elif item.data["mode"] == "random": self._play_dir(item.data["dir"], True) elif item.data["mode"] == "single": self._play_track(item.data["track"]) elif item.data["mode"] == "resume": self._play_resume(item.data["dir"]) elif item.menu_type == MenuType.BACK: return def _play_dir(self, directory: str, random: bool): ic("Playing", directory, random) return def _play_track(self, track: str): ic("Playing", track) player = MPV() player.play(track) player.wait_for_playback() return def _play_resume(self, directory: str): ic("Resuming", directory) return