wip now playing screen

This commit is contained in:
Rudis Muiznieks 2022-12-28 12:48:42 -06:00
parent 753aa11f2c
commit dbd1f301cb
Signed by: rudism
GPG Key ID: CABF2F86EF7884F9
1 changed files with 6 additions and 5 deletions

View File

@ -32,25 +32,26 @@ class MusicPlayer:
def _play_track(self, directory: str, track: str): def _play_track(self, directory: str, track: str):
ic("Playing", track) ic("Playing", track)
self._init_now_playing(track)
player = MPV() player = MPV()
player.play(path.join(directory, track)) player.play(path.join(directory, track))
self._run_now_playing(player)
return return
def _play_resume(self, directory: str): def _play_resume(self, directory: str):
ic("Resuming", directory) ic("Resuming", directory)
return return
def _init_now_playing(self, track_name: str): def _run_now_playing(self, player: MPV):
self._graphics.clear() self._graphics.clear()
self._graphics.text(track_name, 0, 0, 1) self._graphics.text(player.properties["filename"], 0, 0, 1)
self._graphics.text("Pos:", 0, 1, 1) self._graphics.text("Pos:", 0, 1, 1)
self._draw_progress(0, 0) self._draw_progress(0, int(player.properties["duration"] or 0))
self._graphics.show() self._graphics.show()
player.wait_for_playback()
def _draw_progress(self, pos: int, length: int): def _draw_progress(self, pos: int, length: int):
pos_str = self._convert_seconds(pos) pos_str = self._convert_seconds(pos)
if length == 0: if length <= 0:
self._graphics.text(pos_str, 5, 1, 1) self._graphics.text(pos_str, 5, 1, 1)
else: else:
len_str = self._convert_seconds(length) len_str = self._convert_seconds(length)