Preload songs only after the song list has loaded

At startup and after resetting the playlist, loading the song list and
preloading the first song started at the same time. When the list
answered last, it cleared the playlist and dropped the preloaded song.
Preloading now starts once the list has loaded, and loading the list is
retried if it fails.
This commit is contained in:
Sansan committed 2026-10-05 21:10:42 +02:00
1 parent 05655cf81c
commit d856e03c32
5 files changed
+78 -8

No files matched your search

+7 -8
View File
@@ -186,7 +186,6 @@ func _ready() -> void:
get_suggestion_list()
fetch_song_list_at_start()
fetch_song()
search_view.get_list_of_soundtracks()
new_character_select.load_characters()
@@ -240,14 +239,12 @@ func show_answer_pressed() -> void:
Playlist.song_is_answered()
update_song_list()
# Loads the songs already in the server playlist, then starts preloading new ones.
# Preloading waits for the list, because loading the list clears the playlist.
func fetch_song_list_at_start() -> void:
print("fetch_song_list_at_start")
var fetch_song_list_at_start_done: Callable = func fetch_songs_at_start_done(data) -> void:
Playlist.clear_song_list()
if data == null:
Playlist.update_last_played_song()
update_song_list()
return
if typeof(data) == TYPE_ARRAY:
for d: Dictionary in data:
var new_song_object: SongObject = SongObject.new()
@@ -257,11 +254,14 @@ func fetch_song_list_at_start() -> void:
new_song_object.is_answered = true
new_song_object.has_played = true
Playlist.add_to_playlist(new_song_object)
else:
elif data != null:
print("Unexpected data")
Playlist.update_last_played_song()
update_song_list()
MusicServerClient.fetch_song_list(fetch_song_list_at_start_done)
if !Playlist.is_song_downloading:
fetch_song()
MusicServerClient.fetch_song_list(fetch_song_list_at_start_done,
_retry_later.bind(fetch_song_list_at_start))
func play_next_song() -> void:
print("play_next_song ", Playlist.latest_played_song)
@@ -360,7 +360,6 @@ func reset_playlist() -> void:
var playlist_reset_done: Callable = func playlist_reset_done() -> void:
Playlist.reset_playlist()
fetch_song_list_at_start()
fetch_song()
MusicServerClient.reset_playlist(playlist_reset_done)