From 4c71d6a6e06162faa9b80dacbee75555c473dff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Marchal?= Date: Wed, 6 Oct 2021 22:54:55 +0200 Subject: [PATCH] Rough working shuffle system --- Views/MainWindow.xaml.cs | 32 +++++- Views/Settings.xaml | 134 +++++++++++++++---------- Views/Shuffle.xaml | 50 ++++++++-- Views/Shuffle.xaml.cs | 206 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 357 insertions(+), 65 deletions(-) diff --git a/Views/MainWindow.xaml.cs b/Views/MainWindow.xaml.cs index bee00c7..332f606 100644 --- a/Views/MainWindow.xaml.cs +++ b/Views/MainWindow.xaml.cs @@ -6,6 +6,8 @@ using System.Windows.Threading; using System.Windows.Interop; using System.Windows.Input; using System.Windows.Controls.Primitives; +using MpcNET.Commands.Queue; +using System.Diagnostics; namespace unison { @@ -61,9 +63,11 @@ namespace unison } _settingsWin.UpdateConnectionStatus(); Connection.Text = $"{Properties.Settings.Default.mpd_host}:{Properties.Settings.Default.mpd_port}"; + + _shuffleWin.ListGenre(); } - public void OnSongChanged(object sender, EventArgs e) + public async void OnSongChanged(object sender, EventArgs e) { if (_mpd.GetCurrentSong() == null) return; @@ -109,6 +113,32 @@ namespace unison _timer.Start(); EndTime.Text = FormatSeconds(_mpd.GetCurrentSong().Time); } + + Debug.WriteLine("Song changed called!"); + + // handle continuous shuffle + if (_shuffleWin.GetContinuous()) + { + System.Collections.Generic.IEnumerable a = await _mpd.SafelySendCommandAsync(new PlaylistCommand()); + int queueSize = 0; + foreach (var i in a) + { + Debug.WriteLine(i.Path); + queueSize++; + } + Debug.WriteLine("queue size is: " + queueSize); + + if (queueSize < 5) + { + _shuffleWin.AddContinuousSongs(); + } + + // query queue + // if (queue.SongRemaining < 5) + //{ + // // query shuffle songs + //} + } } public void OnStatusChanged(object sender, EventArgs e) diff --git a/Views/Settings.xaml b/Views/Settings.xaml index e498f59..3e8c797 100644 --- a/Views/Settings.xaml +++ b/Views/Settings.xaml @@ -44,59 +44,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -