wip now playing screen
This commit is contained in:
parent
1aec8c7059
commit
769a26a30c
|
@ -32,21 +32,24 @@ 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, 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 _run_now_playing(self, player: MPV, init_name: str):
|
def _init_now_playing(self, init_name: str):
|
||||||
self._graphics.clear()
|
self._graphics.clear()
|
||||||
self._graphics.text(init_name, 0, 0, 1)
|
self._graphics.text(init_name, 0, 0, 1)
|
||||||
self._graphics.text("Pos:", 0, 1, 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()
|
self._graphics.show()
|
||||||
|
|
||||||
|
def _run_now_playing(self, player: MPV):
|
||||||
player.wait_for_playback()
|
player.wait_for_playback()
|
||||||
|
|
||||||
def _draw_progress(self, pos: int, length: int):
|
def _draw_progress(self, pos: int, length: int):
|
||||||
|
@ -64,4 +67,9 @@ class MusicPlayer:
|
||||||
seconds %= 3600
|
seconds %= 3600
|
||||||
minutes = seconds // 60
|
minutes = seconds // 60
|
||||||
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)
|
||||||
|
|
Reference in New Issue