From 32d3610b074f396656b69079ae6c4aee92ca34a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Marchal?= Date: Sun, 3 Oct 2021 13:54:54 +0200 Subject: [PATCH] Progress on radio implementation --- Handlers/MPDHandler.cs | 9 +- Views/MainWindow.xaml.cs | 7 +- Views/Radios.xaml | 69 ++++++++++++-- Views/Radios.xaml.cs | 188 +++++++++++++++++++++++++++++---------- 4 files changed, 215 insertions(+), 58 deletions(-) diff --git a/Handlers/MPDHandler.cs b/Handlers/MPDHandler.cs index bbb4dd2..3203c4e 100644 --- a/Handlers/MPDHandler.cs +++ b/Handlers/MPDHandler.cs @@ -364,7 +364,14 @@ namespace unison else { using MemoryStream stream = new MemoryStream(data.ToArray()); - _cover = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); + try + { + _cover = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad); + } + catch (System.NotSupportedException e) + { + _cover = null; + } } UpdateCover(); } diff --git a/Views/MainWindow.xaml.cs b/Views/MainWindow.xaml.cs index cc3d829..e9004fe 100644 --- a/Views/MainWindow.xaml.cs +++ b/Views/MainWindow.xaml.cs @@ -70,11 +70,12 @@ namespace unison SongTitle.Text = _mpd.GetCurrentSong().Title; else if (_mpd.GetCurrentSong().HasName && _mpd.GetCurrentSong().Name.Length > 0) SongTitle.Text = _mpd.GetCurrentSong().Name; - else + else if (_mpd.GetCurrentSong().Path != null) { int start = _mpd.GetCurrentSong().Path.LastIndexOf("/") + 1; int end = _mpd.GetCurrentSong().Path.LastIndexOf("."); - SongTitle.Text = _mpd.GetCurrentSong().Path.Substring(start, end - start); + if (start > 0 && end > 0 && end > start) + SongTitle.Text = _mpd.GetCurrentSong().Path.Substring(start, end - start); } SongTitle.ToolTip = _mpd.GetCurrentSong().Path; @@ -216,7 +217,7 @@ namespace unison snapcast.LaunchOrExit(); } - public async void Radios_Clicked(object sender, RoutedEventArgs e) + public void Radios_Clicked(object sender, RoutedEventArgs e) { _radiosWin.Show(); _radiosWin.Activate(); diff --git a/Views/Radios.xaml b/Views/Radios.xaml index 2674f40..aed7557 100644 --- a/Views/Radios.xaml +++ b/Views/Radios.xaml @@ -3,20 +3,77 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf" xmlns:local="clr-namespace:unison" mc:Ignorable="d" - Title="Radios" Closing="Window_Closing" SizeToContent="WidthAndHeight"> + Title="Radios" Closing="Window_Closing" SizeToContent="WidthAndHeight" ResizeMode="NoResize"> + + + + + + + + + + + + + + + + + - - -