From fbb65a039ad6bae8c2414d6f2a01d553184c9ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Marchal?= Date: Fri, 1 Oct 2021 02:24:18 +0200 Subject: [PATCH] First POC for a radio browser --- Handlers/MPDHandler.cs | 10 ++++ Views/MainWindow.xaml | 20 +++++--- Views/MainWindow.xaml.cs | 11 ++++ Views/Radios.xaml | 22 ++++++++ Views/Radios.xaml.cs | 107 +++++++++++++++++++++++++++++++++++++++ unison.csproj | 3 +- 6 files changed, 166 insertions(+), 7 deletions(-) create mode 100644 Views/Radios.xaml create mode 100644 Views/Radios.xaml.cs diff --git a/Handlers/MPDHandler.cs b/Handlers/MPDHandler.cs index 3287f1a..bbb4dd2 100644 --- a/Handlers/MPDHandler.cs +++ b/Handlers/MPDHandler.cs @@ -12,6 +12,7 @@ using System.Windows.Threading; using MpcNET; using MpcNET.Commands.Database; using MpcNET.Commands.Playback; +using MpcNET.Commands.Queue; using MpcNET.Commands.Status; using MpcNET.Message; using MpcNET.Types; @@ -439,5 +440,14 @@ namespace unison _currentVolume = 0; SetVolume(_currentVolume); } + + public void ClearQueue() => SendCommand(new ClearCommand()); + public void PlayCommand() => SendCommand(new PlayCommand(0)); + + public void AddSong(string Uri) + { + Debug.WriteLine("AddCommand path: " + Uri); + SendCommand(new AddCommand(Uri)); + } } } \ No newline at end of file diff --git a/Views/MainWindow.xaml b/Views/MainWindow.xaml index 0533491..2f8db06 100644 --- a/Views/MainWindow.xaml +++ b/Views/MainWindow.xaml @@ -110,12 +110,20 @@ - + + + + diff --git a/Views/MainWindow.xaml.cs b/Views/MainWindow.xaml.cs index 4e5057e..cc3d829 100644 --- a/Views/MainWindow.xaml.cs +++ b/Views/MainWindow.xaml.cs @@ -12,6 +12,7 @@ namespace unison public partial class MainWindow : Window { private readonly Settings _settingsWin; + private readonly Radios _radiosWin; private readonly DispatcherTimer _timer; private readonly MPDHandler _mpd; @@ -23,6 +24,7 @@ namespace unison WindowState = WindowState.Minimized; _settingsWin = new Settings(); + _radiosWin = new Radios(); _timer = new DispatcherTimer(); _mpd = (MPDHandler)Application.Current.Properties["mpd"]; @@ -214,6 +216,15 @@ namespace unison snapcast.LaunchOrExit(); } + public async void Radios_Clicked(object sender, RoutedEventArgs e) + { + _radiosWin.Show(); + _radiosWin.Activate(); + + if (_radiosWin.WindowState == WindowState.Minimized) + _radiosWin.WindowState = WindowState.Normal; + } + public void Settings_Clicked(object sender, RoutedEventArgs e) { _settingsWin.Show(); diff --git a/Views/Radios.xaml b/Views/Radios.xaml new file mode 100644 index 0000000..2674f40 --- /dev/null +++ b/Views/Radios.xaml @@ -0,0 +1,22 @@ + + + + + + + +