Update MpcNET from 1.3 to 1.4 to use filters
This commit is contained in:
parent
6ad4d9c813
commit
5d6e3b6d1e
@ -110,14 +110,15 @@
|
|||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid x:Name="BottomLayout" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" Width="Auto" MinHeight="40">
|
<Grid x:Name="BottomLayout" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" Width="Auto" MinHeight="40">
|
||||||
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,0,10,0">
|
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal" VerticalAlignment="Center" Margin="10,0,0,0">
|
||||||
<Button x:Name="Snapcast" HorizontalAlignment="Left" VerticalAlignment="Center" Click="Snapcast_Clicked" Margin="10,0,0,0" Padding="5, 2" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" FocusVisualStyle="{x:Null}" IsEnabled="False">
|
<Button x:Name="Shuffle" Padding="5, 2" Click="Shuffle_Clicked" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" FocusVisualStyle="{x:Null}" Margin="0,0,10,0">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<emoji:TextBlock Text="🔊" Padding="0,0,0,2"/>
|
<emoji:TextBlock Text="🔁" Padding="0,0,0,2"/>
|
||||||
<TextBlock x:Name="SnapcastText" Text="{x:Static properties:Resources.StartSnapcast}" Margin="5, 0, 0, 0"/>
|
<TextBlock Text="Shuffle" Margin="5, 0, 0, 0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
<Button x:Name="Radio" Padding="5, 2" HorizontalAlignment="Left" Click="Radios_Clicked" Margin="5,0,10,0" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" FocusVisualStyle="{x:Null}" IsEnabled="False">
|
|
||||||
|
<Button x:Name="Radio" Padding="5, 2" HorizontalAlignment="Left" Click="Radios_Clicked" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" FocusVisualStyle="{x:Null}" IsEnabled="False">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<emoji:TextBlock Text="📻" Padding="0,0,0,2"/>
|
<emoji:TextBlock Text="📻" Padding="0,0,0,2"/>
|
||||||
<TextBlock Text="{x:Static properties:Resources.Radios}" Margin="5, 0, 0, 0"/>
|
<TextBlock Text="{x:Static properties:Resources.Radios}" Margin="5, 0, 0, 0"/>
|
||||||
@ -135,12 +136,13 @@
|
|||||||
<TextBlock x:Name="Connection" HorizontalAlignment="Center" Text="Not connected" TextWrapping="Wrap" VerticalAlignment="Top" TextAlignment="Center" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" Margin="5,0,0,0" />
|
<TextBlock x:Name="Connection" HorizontalAlignment="Center" Text="Not connected" TextWrapping="Wrap" VerticalAlignment="Top" TextAlignment="Center" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" Margin="5,0,0,0" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,0,10,0">
|
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,0,10,0">
|
||||||
<Button x:Name="Shuffle" Padding="5, 2" Click="Shuffle_Clicked" Margin="0,0,10,0" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" FocusVisualStyle="{x:Null}">
|
<Button x:Name="Snapcast" HorizontalAlignment="Left" VerticalAlignment="Center" Click="Snapcast_Clicked" Margin="0,0,10,0" Padding="5, 2" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" FocusVisualStyle="{x:Null}" IsEnabled="False">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<emoji:TextBlock Text="🔁" Padding="0,0,0,2"/>
|
<emoji:TextBlock Text="🔊" Padding="0,0,0,2"/>
|
||||||
<TextBlock Text="Shuffle" Margin="5, 0, 0, 0"/>
|
<TextBlock x:Name="SnapcastText" Text="{x:Static properties:Resources.StartSnapcast}" Margin="5, 0, 0, 0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button x:Name="Settings" Padding="5, 2" Click="Settings_Clicked" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" FocusVisualStyle="{x:Null}">
|
<Button x:Name="Settings" Padding="5, 2" Click="Settings_Clicked" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" FocusVisualStyle="{x:Null}">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<emoji:TextBlock Text="🛠️" Padding="0,0,0,2"/>
|
<emoji:TextBlock Text="🛠️" Padding="0,0,0,2"/>
|
||||||
|
@ -53,6 +53,9 @@ namespace unison
|
|||||||
Snapcast.IsEnabled = true;
|
Snapcast.IsEnabled = true;
|
||||||
ConnectionOkIcon.Visibility = Visibility.Visible;
|
ConnectionOkIcon.Visibility = Visibility.Visible;
|
||||||
ConnectionFailIcon.Visibility = Visibility.Collapsed;
|
ConnectionFailIcon.Visibility = Visibility.Collapsed;
|
||||||
|
|
||||||
|
_shuffleWin.ListGenre();
|
||||||
|
_shuffleWin.ListFolder();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -63,9 +66,6 @@ namespace unison
|
|||||||
}
|
}
|
||||||
_settingsWin.UpdateConnectionStatus();
|
_settingsWin.UpdateConnectionStatus();
|
||||||
Connection.Text = $"{Properties.Settings.Default.mpd_host}:{Properties.Settings.Default.mpd_port}";
|
Connection.Text = $"{Properties.Settings.Default.mpd_host}:{Properties.Settings.Default.mpd_port}";
|
||||||
|
|
||||||
_shuffleWin.ListGenre();
|
|
||||||
_shuffleWin.ListFolder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void OnSongChanged(object sender, EventArgs e)
|
public async void OnSongChanged(object sender, EventArgs e)
|
||||||
|
@ -44,11 +44,11 @@
|
|||||||
<StackPanel Orientation="Horizontal" Margin="0,5,0,5">
|
<StackPanel Orientation="Horizontal" Margin="0,5,0,5">
|
||||||
<StackPanel Orientation="Vertical">
|
<StackPanel Orientation="Vertical">
|
||||||
<TextBlock Text="Genre" Margin="0,0,0,2"/>
|
<TextBlock Text="Genre" Margin="0,0,0,2"/>
|
||||||
<ComboBox x:Name="Genre" SelectedIndex="0" Width="240" ScrollViewer.CanContentScroll="False" Margin="5,0,0,0"/>
|
<ComboBox x:Name="Genre" SelectedIndex="0" Width="240" ScrollViewer.CanContentScroll="False" Margin="5,0,0,0" FocusVisualStyle="{x:Null}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Vertical" Margin="20,0,0,0">
|
<StackPanel Orientation="Vertical" Margin="20,0,0,0">
|
||||||
<TextBlock Text="Directory" Margin="0,0,0,2" TextDecorations="{x:Null}"/>
|
<TextBlock Text="Directory" Margin="0,0,0,2" TextDecorations="{x:Null}"/>
|
||||||
<ComboBox x:Name="Directory" SelectedIndex="0" Width="240" ScrollViewer.CanContentScroll="False" Margin="5,0,0,0" IsEnabled="False"/>
|
<ComboBox x:Name="Directory" SelectedIndex="0" Width="240" ScrollViewer.CanContentScroll="False" Margin="5,0,0,0" IsEnabled="True"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal" Margin="0,5,0,5">
|
<StackPanel Orientation="Horizontal" Margin="0,5,0,5">
|
||||||
@ -70,7 +70,7 @@
|
|||||||
</TextBlock>
|
</TextBlock>
|
||||||
</GroupBox.Header>
|
</GroupBox.Header>
|
||||||
<StackPanel Orientation="Horizontal" Margin="5,8,0,0">
|
<StackPanel Orientation="Horizontal" Margin="5,8,0,0">
|
||||||
<CheckBox x:Name="ContinuousShuffle" Checked="ContinuousShuffle_Checked" Unchecked="ContinuousShuffle_Checked">
|
<CheckBox x:Name="ContinuousShuffle" Checked="ContinuousShuffle_Checked" Unchecked="ContinuousShuffle_Checked" FocusVisualStyle="{x:Null}">
|
||||||
<TextBlock Text="Enable continuous shuffle" TextWrapping="Wrap"/>
|
<TextBlock Text="Enable continuous shuffle" TextWrapping="Wrap"/>
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
using MpcNET.Commands.Database;
|
using MpcNET.Commands.Database;
|
||||||
using MpcNET.Commands.Reflection;
|
using MpcNET.Commands.Reflection;
|
||||||
using MpcNET.Tags;
|
using MpcNET.Tags;
|
||||||
|
using MpcNET.Types;
|
||||||
|
using MpcNET.Types.Filters;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -24,6 +26,13 @@ namespace unison
|
|||||||
_songList = new();
|
_songList = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsFilterEmpty()
|
||||||
|
{
|
||||||
|
if (Song.Text.Length == 0 && Artist.Text.Length == 0 && Album.Text.Length == 0 && Year.Text.Length == 0 && Genre.SelectedIndex == 0 && Directory.Text.Length == 0)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool GetContinuous()
|
public bool GetContinuous()
|
||||||
{
|
{
|
||||||
return _continuous;
|
return _continuous;
|
||||||
@ -31,8 +40,9 @@ namespace unison
|
|||||||
|
|
||||||
public void AddContinuousSongs()
|
public void AddContinuousSongs()
|
||||||
{
|
{
|
||||||
if (Song.Text.Length == 0 && Artist.Text.Length == 0 && Album.Text.Length == 0 && Year.Text.Length == 0 && Genre.SelectedIndex == 0)
|
if (IsFilterEmpty())
|
||||||
{
|
{
|
||||||
|
// add a completely random song
|
||||||
ContinuousShuffle_AddToQueueRandom();
|
ContinuousShuffle_AddToQueueRandom();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,14 +85,13 @@ namespace unison
|
|||||||
if (Directory.Items.Count == 0)
|
if (Directory.Items.Count == 0)
|
||||||
{
|
{
|
||||||
_mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
_mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
||||||
List<string> Response = await _mpd.SafelySendCommandAsync(new ListFilesCommand());
|
IEnumerable<IMpdFilePath> Response = await _mpd.SafelySendCommandAsync(new LsInfoCommand(""));
|
||||||
|
|
||||||
if (Response.Count > 0)
|
if (Response != null)
|
||||||
{
|
{
|
||||||
Directory.Items.Add("");
|
Directory.Items.Add("");
|
||||||
for (int i = 0; i < Response.Count; i++)
|
foreach (var directory in Response)
|
||||||
if (i % 2 != 1)
|
Directory.Items.Add(directory.Name);
|
||||||
Directory.Items.Add(Response[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,6 +116,7 @@ namespace unison
|
|||||||
Album.Text = "";
|
Album.Text = "";
|
||||||
Year.Text = "";
|
Year.Text = "";
|
||||||
Genre.SelectedIndex = 0;
|
Genre.SelectedIndex = 0;
|
||||||
|
Directory.SelectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ContinuousShuffle_Checked(object sender, RoutedEventArgs e)
|
private async void ContinuousShuffle_Checked(object sender, RoutedEventArgs e)
|
||||||
@ -116,10 +126,7 @@ namespace unison
|
|||||||
AddToQueueGroup.IsEnabled = false;
|
AddToQueueGroup.IsEnabled = false;
|
||||||
_continuous = true;
|
_continuous = true;
|
||||||
_songList.Clear();
|
_songList.Clear();
|
||||||
if (Song.Text.Length == 0 && Artist.Text.Length == 0 && Album.Text.Length == 0 && Year.Text.Length == 0 && Genre.SelectedIndex == 0)
|
if (!IsFilterEmpty())
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/*await*/
|
/*await*/
|
||||||
GetSongsFromFilter();
|
GetSongsFromFilter();
|
||||||
@ -196,16 +203,27 @@ namespace unison
|
|||||||
|
|
||||||
int song = _mpd.GetStats().Songs;
|
int song = _mpd.GetStats().Songs;
|
||||||
|
|
||||||
List<KeyValuePair<ITag, string>> filters = new();
|
List<IFilter> filtersA = new();
|
||||||
filters.Add(new KeyValuePair<ITag, string>(MpdTags.Title, Song.Text));
|
if (Song.Text != "")
|
||||||
filters.Add(new KeyValuePair<ITag, string>(MpdTags.Artist, Artist.Text));
|
filtersA.Add(new FilterTag(MpdTags.Title, Song.Text, FilterOperator.Contains));
|
||||||
filters.Add(new KeyValuePair<ITag, string>(MpdTags.Album, Album.Text));
|
if (Artist.Text != "")
|
||||||
filters.Add(new KeyValuePair<ITag, string>(MpdTags.Date, Year.Text));
|
filtersA.Add(new FilterTag(MpdTags.Artist, Artist.Text, FilterOperator.Contains));
|
||||||
filters.Add(new KeyValuePair<ITag, string>(MpdTags.Genre, Genre.Text));
|
if (Album.Text != "")
|
||||||
|
filtersA.Add(new FilterTag(MpdTags.Album, Album.Text, FilterOperator.Contains));
|
||||||
|
if (Year.Text != "")
|
||||||
|
filtersA.Add(new FilterTag(MpdTags.Date, Year.Text, FilterOperator.Contains));
|
||||||
|
if (Genre.Text != "")
|
||||||
|
filtersA.Add(new FilterTag(MpdTags.Genre, Genre.Text, FilterOperator.Contains));
|
||||||
|
if (Directory.Text != "")
|
||||||
|
filtersA.Add(new FilterBase(Directory.Text, FilterOperator.None));
|
||||||
|
|
||||||
CommandList commandList = new CommandList(new IMpcCommand<object>[] { new SearchCommand(filters, 0, song + 1) });
|
Debug.WriteLine(Directory.Text);
|
||||||
|
|
||||||
|
CommandList commandList = new CommandList(new IMpcCommand<object>[] { new SearchCommand(filtersA, 0, song + 1) });
|
||||||
string Response = await _mpd.SafelySendCommandAsync(commandList);
|
string Response = await _mpd.SafelySendCommandAsync(commandList);
|
||||||
|
|
||||||
|
Debug.WriteLine(Response);
|
||||||
|
|
||||||
// create a list of the file url
|
// create a list of the file url
|
||||||
string[] value = Response.Split(", [file, ");
|
string[] value = Response.Split(", [file, ");
|
||||||
|
|
||||||
@ -222,6 +240,7 @@ namespace unison
|
|||||||
int end = file.IndexOf("],");
|
int end = file.IndexOf("],");
|
||||||
string filePath = file.Substring(start, end - start);
|
string filePath = file.Substring(start, end - start);
|
||||||
|
|
||||||
|
Debug.WriteLine(filePath);
|
||||||
_songList.Add(filePath);
|
_songList.Add(filePath);
|
||||||
|
|
||||||
SongFilterNumber.Text = _songList.Count.ToString();
|
SongFilterNumber.Text = _songList.Count.ToString();
|
||||||
@ -232,12 +251,6 @@ namespace unison
|
|||||||
|
|
||||||
SongFilterPanel.Visibility = Visibility.Visible;
|
SongFilterPanel.Visibility = Visibility.Visible;
|
||||||
SongFilterNumber.Text = _songList.Count.ToString();
|
SongFilterNumber.Text = _songList.Count.ToString();
|
||||||
|
|
||||||
// DEBUG
|
|
||||||
//foreach (var a in _songList)
|
|
||||||
// Debug.WriteLine(a);
|
|
||||||
Debug.WriteLine("number of songs found: " + _songList.Count);
|
|
||||||
Debug.WriteLine("number of songs requested: " + int.Parse(SongNumber.Text));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void AddToQueueFilter()
|
private async void AddToQueueFilter()
|
||||||
@ -285,7 +298,7 @@ namespace unison
|
|||||||
if (_mpd.GetStats() == null)
|
if (_mpd.GetStats() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Song.Text.Length == 0 && Artist.Text.Length == 0 && Album.Text.Length == 0 && Year.Text.Length == 0 && Genre.SelectedIndex == 0)
|
if (IsFilterEmpty())
|
||||||
AddToQueueRandom();
|
AddToQueueRandom();
|
||||||
else
|
else
|
||||||
AddToQueueFilter();
|
AddToQueueFilter();
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<ApplicationIcon>Resources\icon-full.ico</ApplicationIcon>
|
<ApplicationIcon>Resources\icon-full.ico</ApplicationIcon>
|
||||||
<Win32Resource></Win32Resource>
|
<Win32Resource></Win32Resource>
|
||||||
<StartupObject>unison.App</StartupObject>
|
<StartupObject>unison.App</StartupObject>
|
||||||
<Version>1.2</Version>
|
<Version>1.3</Version>
|
||||||
<Company />
|
<Company />
|
||||||
<Authors>Théo Marchal</Authors>
|
<Authors>Théo Marchal</Authors>
|
||||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||||
@ -47,7 +47,7 @@
|
|||||||
<PackageReference Include="Emoji.Wpf" Version="0.3.3" />
|
<PackageReference Include="Emoji.Wpf" Version="0.3.3" />
|
||||||
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.1.0" />
|
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.1.0" />
|
||||||
<PackageReference Include="RadioBrowser" Version="0.6.1" />
|
<PackageReference Include="RadioBrowser" Version="0.6.1" />
|
||||||
<PackageReference Include="MpcNET" Version="1.3.0" />
|
<PackageReference Include="MpcNET" Version="1.4.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user