From 3124613c3a26c09f69fe36b9e781cb97002155a1 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Tue, 29 Nov 2022 21:56:33 +0300 Subject: [PATCH] More accesible play\pause buttons (partially no static) --- src/fw_radios.py | 7 +++++-- src/mpv_control.py | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/fw_radios.py b/src/fw_radios.py index 344eeac..86f9903 100644 --- a/src/fw_radios.py +++ b/src/fw_radios.py @@ -102,11 +102,16 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non radio_task = threading.Thread(target=radio_generator, args=(radio_session_id,), daemon=True) radio_task.start() player_items_menu = ['Next', 'Prev', 'Pause', 'Download', 'Info'] + if show_like_button: player_items_menu.append('Like') player_items_menu.extend(['Hide artist', 'Exit']) while True: try: + if player.pause: + player_items_menu[2] = 'Play' + else: + player_items_menu[2] = 'Pause' select = fzf.prompt(player_items_menu, f"--header=\'Radio {name} playing...\'")[0] if select == 'Next': playlist_remaining = len(player.playlist) - player.playlist_current_pos @@ -117,10 +122,8 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non player.playlist_prev() elif select in ('Pause', 'Play'): if player.pause: - player_items_menu[2] = 'Pause' player.pause = False else: - player_items_menu[2] = 'Play' player.pause = True elif select == 'Download': print('Downloading...') diff --git a/src/mpv_control.py b/src/mpv_control.py index 0eead01..7ec2f42 100644 --- a/src/mpv_control.py +++ b/src/mpv_control.py @@ -38,6 +38,10 @@ def player_menu(header='', storage={}): try: player_items_menu = ['Next', 'Prev', 'Pause', 'Download', 'Info'] + if player.pause: + player_items_menu[2] = 'Play' + else: + player_items_menu[2] = 'Pause' if show_like_button: player_items_menu.append('Like') player_items_menu.extend(['Hide artist', 'Exit']) @@ -47,7 +51,7 @@ def player_menu(header='', storage={}): player.playlist_next() elif select == 'Prev': player.playlist_prev() - elif select == 'Pause': + elif select in ('Pause', 'Play'): if player.pause: player.pause = False else: