wip now playing screen
This commit is contained in:
parent
753aa11f2c
commit
dbd1f301cb
|
@ -32,25 +32,26 @@ 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)
|
||||
return
|
||||
|
||||
def _play_resume(self, directory: str):
|
||||
ic("Resuming", directory)
|
||||
return
|
||||
|
||||
def _init_now_playing(self, track_name: str):
|
||||
def _run_now_playing(self, player: MPV):
|
||||
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._draw_progress(0, 0)
|
||||
self._draw_progress(0, int(player.properties["duration"] or 0))
|
||||
self._graphics.show()
|
||||
player.wait_for_playback()
|
||||
|
||||
def _draw_progress(self, pos: int, length: int):
|
||||
pos_str = self._convert_seconds(pos)
|
||||
if length == 0:
|
||||
if length <= 0:
|
||||
self._graphics.text(pos_str, 5, 1, 1)
|
||||
else:
|
||||
len_str = self._convert_seconds(length)
|
||||
|
|
Reference in New Issue