started on now-playing screen
This commit is contained in:
parent
2e42703725
commit
7bd634ee31
|
@ -26,7 +26,7 @@ def create_directory_menu(directory: str, dirname: str, is_resume: bool):
|
||||||
track_menu.append(MenuItem(fname, MenuType.CMD, {
|
track_menu.append(MenuItem(fname, MenuType.CMD, {
|
||||||
"dir": directory,
|
"dir": directory,
|
||||||
"mode": "single",
|
"mode": "single",
|
||||||
"track": path.join(directory, fname)}))
|
"track": fname}))
|
||||||
if len(dir_menu) > 0:
|
if len(dir_menu) > 0:
|
||||||
return MenuItem(dirname, MenuType.SUB_MENU, {"sub_menu": dir_menu})
|
return MenuItem(dirname, MenuType.SUB_MENU, {"sub_menu": dir_menu})
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from os import path
|
||||||
from menu import Menu, MenuType
|
from menu import Menu, MenuType
|
||||||
from cinput import ControlInput
|
from cinput import ControlInput
|
||||||
from graphics import Graphics
|
from graphics import Graphics
|
||||||
|
@ -19,7 +20,7 @@ class MusicPlayer:
|
||||||
elif item.data["mode"] == "random":
|
elif item.data["mode"] == "random":
|
||||||
self._play_dir(item.data["dir"], True)
|
self._play_dir(item.data["dir"], True)
|
||||||
elif item.data["mode"] == "single":
|
elif item.data["mode"] == "single":
|
||||||
self._play_track(item.data["track"])
|
self._play_track(item.data["dir"], item.data["track"])
|
||||||
elif item.data["mode"] == "resume":
|
elif item.data["mode"] == "resume":
|
||||||
self._play_resume(item.data["dir"])
|
self._play_resume(item.data["dir"])
|
||||||
elif item.menu_type == MenuType.BACK:
|
elif item.menu_type == MenuType.BACK:
|
||||||
|
@ -29,13 +30,18 @@ class MusicPlayer:
|
||||||
ic("Playing", directory, random)
|
ic("Playing", directory, random)
|
||||||
return
|
return
|
||||||
|
|
||||||
def _play_track(self, track: str):
|
def _play_track(self, directory: str, track: str):
|
||||||
ic("Playing", track)
|
ic("Playing", track)
|
||||||
|
self._draw_now_playing(track)
|
||||||
player = MPV()
|
player = MPV()
|
||||||
player.play(track)
|
player.play(path.join(directory, track))
|
||||||
player.wait_for_playback()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _play_resume(self, directory: str):
|
def _play_resume(self, directory: str):
|
||||||
ic("Resuming", directory)
|
ic("Resuming", directory)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def _draw_now_playing(self, track_name: str):
|
||||||
|
self._graphics.clear()
|
||||||
|
self._graphics.rect(0, 0, 128, 64, 1)
|
||||||
|
self._graphics.text(track_name, 2, 2, 1)
|
||||||
|
|
Reference in New Issue