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

View File

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