From cd55c0a6fdea1ec5b8433e4e6e755a958f758385 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Thu, 24 Nov 2022 04:12:34 +0300 Subject: [PATCH] Add some conditions for preloading tracks in player playlist --- src/fw_radios.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/fw_radios.py b/src/fw_radios.py index 8490c68..344eeac 100644 --- a/src/fw_radios.py +++ b/src/fw_radios.py @@ -77,7 +77,9 @@ def radio_generator(radio_session_id): count_t += 1 if count_t >= 60: count_t = 0 - radio_get_track(radio_session_id) + playlist_remaining = len(player.playlist) - player.playlist_current_pos + if playlist_remaining <= 2: + radio_get_track(radio_session_id) logger.info('Radio generator stopped') radio_event_gen = threading.Event() @@ -107,7 +109,9 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non try: select = fzf.prompt(player_items_menu, f"--header=\'Radio {name} playing...\'")[0] if select == 'Next': - threading.Thread(target=radio_get_track, args=(radio_session_id,), daemon=True).start() + playlist_remaining = len(player.playlist) - player.playlist_current_pos + if playlist_remaining <= 2: + threading.Thread(target=radio_get_track, args=(radio_session_id,), daemon=True).start() player.playlist_next() elif select == 'Prev': player.playlist_prev()