From eac531c3737bd4e71ef0f90ba15348bfd64b151d Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Mon, 14 Nov 2022 23:28:01 +0300 Subject: [PATCH] mpv player menu if not stopped display button in main menu --- funkwhale_cli.py | 5 +++++ src/mpv_control.py | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/funkwhale_cli.py b/funkwhale_cli.py index dd354fb..4719b35 100644 --- a/funkwhale_cli.py +++ b/funkwhale_cli.py @@ -6,6 +6,7 @@ from src.fw_tracks import list_tracks from src.fw_channels import list_channels from src.fw_playlists import list_playlists import src.settings as settings +import src.mpv_control import json, sys from loguru import logger from pyfzf.pyfzf import FzfPrompt @@ -24,6 +25,8 @@ def main(): 'Switch instance'] if not s.headers.get('Authorization'): menu.append('Sign in') + if not src.mpv_control.player.core_idle: + menu.insert(0, 'Player') ids = fzf.prompt(menu) selected = ids[0] @@ -71,6 +74,8 @@ Insert token from "Access token" here''') del f select_instance(instance) + if selected == 'Player': + src.mpv_control.player_menu(storage=src.mpv_control.player_fw_storage.storage) diff --git a/src/mpv_control.py b/src/mpv_control.py index 27f841e..3a35112 100644 --- a/src/mpv_control.py +++ b/src/mpv_control.py @@ -12,12 +12,18 @@ player.ytdl = False # Prevent attempts load track with yt-dlp player.prefetch_playlist = get_config('prefetch_playlist') # Fast loading next track, but high network traffic show_like_button = get_config('show_like_button') + +class player_fw_storage: + storage = {} + + def set_http_header(headers=[]): player.http_header_fields = headers @logger.catch -def player_menu(header=None, storage={}): +def player_menu(header='', storage={}): + player_fw_storage.storage = storage while True: try: player_items_menu = ['Next', 'Prev', 'Pause',