GetPlaylist more cleverly

This commit is contained in:
Théo Marchal 2022-04-19 01:17:48 +02:00
parent a6b7ad9c1e
commit 5142477b5e
2 changed files with 9 additions and 13 deletions

View File

@ -54,9 +54,6 @@ namespace unison
_mpd.QueryStats();
_settingsWin.UpdateStats();
// _mpd.QueryPlaylist().ConfigureAwait(false);
// to remove
ConnectionOkIcon.Visibility = Visibility.Visible;
ConnectionFailIcon.Visibility = Visibility.Collapsed;
@ -132,18 +129,12 @@ namespace unison
if (!_shuffleWin.GetContinuous())
return;
await Task.Run(async () =>
{
Debug.WriteLine("start continuous");
Debug.WriteLine("playlist length => " + _mpd.GetStatus().PlaylistLength);
await _mpd.QueryPlaylist();
Debug.WriteLine("queried playlist");
});
if (_mpd.GetPlaylistCount() > 5)
if (_mpd.GetStatus().PlaylistLength > 4)
return;
Debug.WriteLine("start continuous handling");
_mpd.CanPrevNext = false;
await _shuffleWin.HandleContinuous();
_mpd.CanPrevNext = true;

View File

@ -342,9 +342,14 @@ namespace unison
public async Task HandleContinuous()
{
if (!_continuous)
{
Debug.WriteLine("continuous return nothing!");
return;
}
Debug.WriteLine("continuous __before__ add to queue");
await AddToQueue(5);
Debug.WriteLine("continuous __after__ add to queue");
}
private async void ContinuousShuffle_Checked(object sender, RoutedEventArgs e)
@ -354,7 +359,7 @@ namespace unison
else
_continuous = false;
if (_mpd.GetPlaylistCount() < 5)
if (_mpd.GetStatus().PlaylistLength < 5)
await HandleContinuous();
}
}