Add some conditions for preloading tracks in player playlist

This commit is contained in:
localhost_frssoft 2022-11-24 04:12:34 +03:00
parent baa7974641
commit cd55c0a6fd

View file

@ -77,7 +77,9 @@ def radio_generator(radio_session_id):
count_t += 1 count_t += 1
if count_t >= 60: if count_t >= 60:
count_t = 0 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') logger.info('Radio generator stopped')
radio_event_gen = threading.Event() radio_event_gen = threading.Event()
@ -107,7 +109,9 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non
try: try:
select = fzf.prompt(player_items_menu, f"--header=\'Radio {name} playing...\'")[0] select = fzf.prompt(player_items_menu, f"--header=\'Radio {name} playing...\'")[0]
if select == 'Next': 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() player.playlist_next()
elif select == 'Prev': elif select == 'Prev':
player.playlist_prev() player.playlist_prev()