trying to play a track
This commit is contained in:
parent
c0be9136a5
commit
a92e22a3ba
|
@ -26,7 +26,7 @@ def create_directory_menu(directory: str, dirname: str, is_resume: bool):
|
|||
track_menu.append(MenuItem(fname, MenuType.CMD, {
|
||||
"dir": directory,
|
||||
"mode": "single",
|
||||
"track": fname}))
|
||||
"track": path.join(directory, fname)}))
|
||||
if len(dir_menu) > 0:
|
||||
return MenuItem(dirname, MenuType.SUB_MENU, {"sub_menu": dir_menu})
|
||||
else:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from menu import Menu, MenuType
|
||||
from cinput import ControlInput
|
||||
from graphics import Graphics
|
||||
from mpv import MPV
|
||||
|
||||
class MusicPlayer:
|
||||
def __init__(self, cinput: ControlInput, graphics: Graphics, menu: Menu):
|
||||
|
@ -11,5 +12,26 @@ class MusicPlayer:
|
|||
def run(self):
|
||||
while True:
|
||||
item = self._menu.get_selection()
|
||||
if item.menu_type == MenuType.BACK:
|
||||
if item.menu_type == MenuType.CMD:
|
||||
if item.data["mode"] == "album":
|
||||
self._play_dir(item.data["dir"], False)
|
||||
elif item.data["mode"] == "random":
|
||||
self._play_dir(item.data["dir"], True)
|
||||
elif item.data["mode"] == "track":
|
||||
self._play_track(item.data["track"])
|
||||
elif item.data["mode"] == "resume":
|
||||
self._play_resume(item.data["dir"])
|
||||
elif item.menu_type == MenuType.BACK:
|
||||
return
|
||||
|
||||
def _play_dir(self, directory: str, random: bool):
|
||||
return
|
||||
|
||||
def _play_track(self, track: str):
|
||||
player = MPV()
|
||||
player.play(track)
|
||||
player.wait_for_playback()
|
||||
return
|
||||
|
||||
def _play_resume(self, directory: str):
|
||||
return
|
||||
|
|
Reference in New Issue