0
1
mirror of https://github.com/radio95-rnt/RadioPlayer.git synced 2026-02-27 14:13:55 +01:00

get rid of quiet reloads

This commit is contained in:
Kuba
2025-10-23 19:43:18 +02:00
parent eea8b9c608
commit 17c08bb51a
3 changed files with 10 additions and 14 deletions

View File

@@ -37,11 +37,11 @@ class PlaylistAdvisor:
Arguments are the arguments passed to the program on startup Arguments are the arguments passed to the program on startup
""" """
return "/path/to/playlist.txt" return "/path/to/playlist.txt"
def new_playlist(self) -> int: def new_playlist(self) -> bool:
""" """
Whether to play a new playlist, if this is 1, then the player will refresh, if this is two then the player will refresh quietly Whether to play a new playlist, if this is True, then the player will refresh and fetch a new playlist, calling advise
""" """
return 0 return False
def imc(self, imc: 'InterModuleCommunication'): def imc(self, imc: 'InterModuleCommunication'):
""" """
Receive an IMC object Receive an IMC object

View File

@@ -98,16 +98,15 @@ class Module(PlaylistAdvisor):
self.last_mod_time = Time.get_playlist_modification_time(night_playlist) self.last_mod_time = Time.get_playlist_modification_time(night_playlist)
self.last_playlist = night_playlist self.last_playlist = night_playlist
return night_playlist return night_playlist
def new_playlist(self) -> int: def new_playlist(self) -> bool:
if self.custom_playlist: return 0 if self.custom_playlist: return False
if not self.last_playlist: return 1 if not self.last_playlist: return True
time_change = check_if_playlist_modifed(self.last_playlist) if check_if_playlist_modifed(self.last_playlist): return True
if time_change: return 2
mod_time = Time.get_playlist_modification_time(self.last_playlist) mod_time = Time.get_playlist_modification_time(self.last_playlist)
if mod_time > self.last_mod_time: if mod_time > self.last_mod_time:
logger.info("Playlist changed on disc, reloading...") logger.info("Playlist changed on disc, reloading...")
return 1 return True
return 0 return False
def imc(self, imc: InterModuleCommunication): def imc(self, imc: InterModuleCommunication):
self.class_imc = imc self.class_imc = imc
imc.register(self, "advisor") imc.register(self, "advisor")

View File

@@ -217,13 +217,10 @@ def play_playlist(playlist_path):
refresh = playlist_advisor.new_playlist() refresh = playlist_advisor.new_playlist()
if refresh == 1: if refresh == True:
logger.info("Reloading now...") logger.info("Reloading now...")
return_pending = True return_pending = True
continue continue
elif refresh == 2:
return_pending = True
if not procman.anything_playing(): continue
for module in simple_modules: module.on_new_track(song_i, track_path, to_fade_in, to_fade_out, official) for module in simple_modules: module.on_new_track(song_i, track_path, to_fade_in, to_fade_out, official)