wip now playing screen

This commit is contained in:
Rudis Muiznieks 2022-12-28 12:59:10 -06:00
parent 1aec8c7059
commit 769a26a30c
Signed by: rudism
GPG Key ID: CABF2F86EF7884F9
1 changed files with 12 additions and 4 deletions

View File

@ -32,21 +32,24 @@ class MusicPlayer:
def _play_track(self, directory: str, track: str):
ic("Playing", track)
self._init_now_playing(track)
player = MPV()
player.play(path.join(directory, track))
self._run_now_playing(player, track)
self._run_now_playing(player)
return
def _play_resume(self, directory: str):
ic("Resuming", directory)
return
def _run_now_playing(self, player: MPV, init_name: str):
def _init_now_playing(self, init_name: str):
self._graphics.clear()
self._graphics.text(init_name, 0, 0, 1)
self._graphics.text("Pos:", 0, 1, 1)
self._draw_progress(0, int(player.properties["duration"] or 0))
self._draw_progress(0, 0)
self._graphics.show()
def _run_now_playing(self, player: MPV):
player.wait_for_playback()
def _draw_progress(self, pos: int, length: int):
@ -64,4 +67,9 @@ class MusicPlayer:
seconds %= 3600
minutes = seconds // 60
seconds %= 60
return "%d:%02d:%02d" % (hours, minutes, seconds)
if hours > 0:
return "%d:%02d:%02d" % (hours, minutes, seconds)
elif minutes > 0:
return "%d:%02d" % (minutes, seconds)
else:
return "%02d" % (seconds)