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,6 +77,8 @@ 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
playlist_remaining = len(player.playlist) - player.playlist_current_pos
if playlist_remaining <= 2:
radio_get_track(radio_session_id) radio_get_track(radio_session_id)
logger.info('Radio generator stopped') logger.info('Radio generator stopped')
@ -107,6 +109,8 @@ 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':
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() 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':