You've already forked RadioPlayer
mirror of
https://github.com/radio95-rnt/RadioPlayer.git
synced 2026-02-27 06:03:52 +01:00
fix loading
This commit is contained in:
@@ -384,7 +384,7 @@ def parse_arguments():
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
# Load state at startup
|
# Load state at startup
|
||||||
load_state()
|
state_loaded = load_state()
|
||||||
|
|
||||||
while True: # Main reload loop
|
while True: # Main reload loop
|
||||||
arg, play_newest_first, do_shuffle, pre_track_path, selected_list = parse_arguments()
|
arg, play_newest_first, do_shuffle, pre_track_path, selected_list = parse_arguments()
|
||||||
@@ -406,6 +406,25 @@ def main():
|
|||||||
logger.info("Reload requested, restarting with new arguments...")
|
logger.info("Reload requested, restarting with new arguments...")
|
||||||
continue # Restart the main loop
|
continue # Restart the main loop
|
||||||
|
|
||||||
|
# Check if we should resume from loaded state first
|
||||||
|
if state_loaded and current_state.get("current_file") and current_state.get("playlist_path"):
|
||||||
|
# Try to resume from the loaded state
|
||||||
|
if os.path.exists(current_state["playlist_path"]):
|
||||||
|
logger.info(f"Attempting to resume from saved state: {current_state['playlist_path']}")
|
||||||
|
result = play_playlist(current_state["playlist_path"],
|
||||||
|
current_state["playlist_path"] != os.path.join(playlist_dir, get_current_day(), 'morning') and
|
||||||
|
current_state["playlist_path"] != os.path.join(playlist_dir, get_current_day(), 'day') and
|
||||||
|
current_state["playlist_path"] != os.path.join(playlist_dir, get_current_day(), 'night') and
|
||||||
|
current_state["playlist_path"] != os.path.join(playlist_dir, get_current_day(), 'late_night'),
|
||||||
|
play_newest_first, do_shuffle)
|
||||||
|
state_loaded = False # Don't try to resume again
|
||||||
|
if result == "reload":
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
logger.warning(f"Saved playlist path no longer exists: {current_state['playlist_path']}")
|
||||||
|
clear_current_state()
|
||||||
|
state_loaded = False
|
||||||
|
|
||||||
playlist_loop_active = True
|
playlist_loop_active = True
|
||||||
while playlist_loop_active:
|
while playlist_loop_active:
|
||||||
if selected_list:
|
if selected_list:
|
||||||
|
|||||||
Reference in New Issue
Block a user