starting on music player
This commit is contained in:
parent
888f777705
commit
10f7213658
|
@ -0,0 +1,22 @@
|
|||
from os import path, listdir
|
||||
from menu import Menu, MenuItem, MenuType
|
||||
from cinput import ControlInput
|
||||
from graphics import Graphics
|
||||
from .player import MusicPlayer
|
||||
|
||||
def execute(cinput: ControlInput, graphics: Graphics, directory: str):
|
||||
current_dir = path.join("/home/rudism", directory)
|
||||
top_menu = create_directory_menu(current_dir, "music")
|
||||
menu = Menu(top_menu.data["sub_dir"], cinput, graphics)
|
||||
MusicPlayer(cinput, graphics, menu).run()
|
||||
|
||||
def create_directory_menu(directory: str, dirname: str):
|
||||
sub_menu = list()
|
||||
for fname in listdir(directory):
|
||||
new_path = path.join(directory, fname)
|
||||
if path.isdir(new_path):
|
||||
sub_menu.append(create_directory_menu(new_path, fname))
|
||||
if len(sub_menu) > 0:
|
||||
return MenuItem(dirname, MenuType.SUB_MENU, {"sub_menu": sub_menu})
|
||||
else:
|
||||
return MenuItem(dirname, MenuType.CMD, {"directory": directory})
|
|
@ -0,0 +1,13 @@
|
|||
from menu import Menu
|
||||
from cinput import ControlInput
|
||||
from graphics import Graphics
|
||||
|
||||
class MusicPlayer:
|
||||
def __init__(self, cinput: ControlInput, graphics: Graphics, menu: Menu):
|
||||
self._cinput = cinput
|
||||
self._graphics = graphics
|
||||
self._menu = menu
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
self._menu.get_selection()
|
Reference in New Issue