Compare commits
2 Commits
4c71d6a6e0
...
c93a9a326e
Author | SHA1 | Date | |
---|---|---|---|
c93a9a326e | |||
c055c59de7 |
@ -497,21 +497,23 @@ namespace unison
|
|||||||
|
|
||||||
public async void QueryStats()
|
public async void QueryStats()
|
||||||
{
|
{
|
||||||
Dictionary<string, string> response = await SafelySendCommandAsync(new StatsCommand());
|
Dictionary<string, string> Response = await SafelySendCommandAsync(new StatsCommand());
|
||||||
|
if (Response == null)
|
||||||
|
return;
|
||||||
|
|
||||||
_stats.Songs = int.Parse(response["songs"]);
|
_stats.Songs = int.Parse(Response["songs"]);
|
||||||
_stats.Albums = int.Parse(response["albums"]);
|
_stats.Albums = int.Parse(Response["albums"]);
|
||||||
_stats.Artists = int.Parse(response["artists"]);
|
_stats.Artists = int.Parse(Response["artists"]);
|
||||||
|
|
||||||
TimeSpan time;
|
TimeSpan time;
|
||||||
time = TimeSpan.FromSeconds(int.Parse(response["uptime"]));
|
time = TimeSpan.FromSeconds(int.Parse(Response["uptime"]));
|
||||||
_stats.Uptime = time.ToString(@"dd\:hh\:mm\:ss");
|
_stats.Uptime = time.ToString(@"dd\:hh\:mm\:ss");
|
||||||
time = TimeSpan.FromSeconds(int.Parse(response["db_playtime"]));
|
time = TimeSpan.FromSeconds(int.Parse(Response["db_playtime"]));
|
||||||
_stats.TotalPlaytime = time.ToString(@"dd\:hh\:mm\:ss");
|
_stats.TotalPlaytime = time.ToString(@"dd\:hh\:mm\:ss");
|
||||||
time = TimeSpan.FromSeconds(int.Parse(response["playtime"]));
|
time = TimeSpan.FromSeconds(int.Parse(Response["playtime"]));
|
||||||
_stats.TotalTimePlayed = time.ToString(@"dd\:hh\:mm\:ss");
|
_stats.TotalTimePlayed = time.ToString(@"dd\:hh\:mm\:ss");
|
||||||
|
|
||||||
DateTime date = new DateTime(1970, 1, 1).AddSeconds(int.Parse(response["db_update"])).ToLocalTime();
|
DateTime date = new DateTime(1970, 1, 1).AddSeconds(int.Parse(Response["db_update"])).ToLocalTime();
|
||||||
_stats.DatabaseUpdate = date.ToString("dd/MM/yyyy @ HH:mm");
|
_stats.DatabaseUpdate = date.ToString("dd/MM/yyyy @ HH:mm");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@ namespace unison
|
|||||||
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.ListGenre();
|
||||||
|
_shuffleWin.ListFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void OnSongChanged(object sender, EventArgs e)
|
public async void OnSongChanged(object sender, EventArgs e)
|
||||||
|
@ -57,8 +57,8 @@
|
|||||||
<Grid>
|
<Grid>
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock Text="{x:Static properties:Resources.Settings_VolumeOffset}" TextWrapping="Wrap" Margin="0,2,0,0"/>
|
<TextBox x:Name="VolumeOffset" TextWrapping="Wrap" Width="25" PreviewTextInput="NumberValidationTextBox" Margin="0,2,0,0"/>
|
||||||
<TextBox x:Name="VolumeOffset" TextWrapping="Wrap" Width="25" PreviewTextInput="NumberValidationTextBox" Margin="8,2,0,0"/>
|
<TextBlock Text="{x:Static properties:Resources.Settings_VolumeOffset}" TextWrapping="Wrap" Margin="5,2,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Grid MinWidth="300" Margin="0,5,0,0">
|
<Grid MinWidth="300" Margin="0,5,0,0">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@ -137,7 +137,11 @@
|
|||||||
</GroupBox.Header>
|
</GroupBox.Header>
|
||||||
<Grid MaxWidth="500">
|
<Grid MaxWidth="500">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock TextWrapping="Wrap">
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBox TextWrapping="Wrap" Width="25" PreviewTextInput="NumberValidationTextBox" Margin="0,2,0,0"/>
|
||||||
|
<TextBlock Text="Prevent repetition rate (0-100%)" TextWrapping="Wrap" Margin="5,2,0,0"/>
|
||||||
|
</StackPanel>
|
||||||
|
<TextBlock TextWrapping="Wrap" Margin="0,10,0,0">
|
||||||
<Run>The shuffle window allows to add random songs to your queue. Both options take into account the filter.</Run>
|
<Run>The shuffle window allows to add random songs to your queue. Both options take into account the filter.</Run>
|
||||||
<Run>If the filter is empty, the entire music library is taken into account.</Run><LineBreak/><LineBreak/>
|
<Run>If the filter is empty, the entire music library is taken into account.</Run><LineBreak/><LineBreak/>
|
||||||
<Run FontWeight="Bold">Continuous shuffle</Run><LineBreak/>
|
<Run FontWeight="Bold">Continuous shuffle</Run><LineBreak/>
|
||||||
|
@ -22,31 +22,37 @@
|
|||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<StackPanel Orientation="Vertical">
|
<StackPanel Orientation="Vertical">
|
||||||
<TextBlock Text="Song" Margin="0,0,0,2"/>
|
<TextBlock Text="Song" Margin="0,0,0,2"/>
|
||||||
<TextBox x:Name="Song" Width="240"/>
|
<TextBox x:Name="Song" Width="240" Margin="5,0,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel Orientation="Vertical" Margin="20,0,0,0">
|
<StackPanel Orientation="Vertical" Margin="20,0,0,0">
|
||||||
<TextBlock Text="Artist" Margin="0,0,0,2"/>
|
<TextBlock Text="Artist" Margin="0,0,0,2"/>
|
||||||
<TextBox x:Name="Artist" Width="240"/>
|
<TextBox x:Name="Artist" Width="240" Margin="5,0,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
|
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
|
||||||
<StackPanel Orientation="Vertical">
|
<StackPanel Orientation="Vertical">
|
||||||
<TextBlock Text="Album" Margin="0,0,0,2"/>
|
<TextBlock Text="Album" Margin="0,0,0,2"/>
|
||||||
<TextBox x:Name="Album" Width="240"/>
|
<TextBox x:Name="Album" Width="240" Margin="5,0,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<StackPanel Orientation="Vertical" Margin="20,0,0,0">
|
<StackPanel Orientation="Vertical" Margin="20,0,0,0">
|
||||||
<TextBlock Text="Year" Margin="0,0,0,2"/>
|
<TextBlock Text="Year" Margin="0,0,0,2"/>
|
||||||
<TextBox x:Name="Year" Width="240"/>
|
<TextBox x:Name="Year" Width="240" Margin="5,0,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<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"/>
|
<ComboBox x:Name="Genre" SelectedIndex="0" Width="240" ScrollViewer.CanContentScroll="False" Margin="5,0,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Button Content="Reset" Click="Reset_Clicked" Padding="5, 2" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="20,0,0,0" FocusVisualStyle="{x:Null}"/>
|
<StackPanel Orientation="Vertical" Margin="20,0,0,0">
|
||||||
|
<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"/>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,5,0,5">
|
||||||
|
<Button Content="Reset" Click="Reset_Clicked" Padding="5, 2" VerticalAlignment="Bottom" HorizontalAlignment="Left" FocusVisualStyle="{x:Null}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel x:Name="SongFilterPanel" Margin="0,5,0,0" Visibility="Collapsed">
|
<StackPanel x:Name="SongFilterPanel" Margin="0,5,0,0" Visibility="Collapsed">
|
||||||
<TextBlock>
|
<TextBlock>
|
||||||
|
@ -10,8 +10,6 @@ using System.Threading.Tasks;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
|
|
||||||
// https://mpd.readthedocs.io/en/stable/protocol.html#binary
|
|
||||||
|
|
||||||
namespace unison
|
namespace unison
|
||||||
{
|
{
|
||||||
public partial class Shuffle : Window
|
public partial class Shuffle : Window
|
||||||
@ -33,6 +31,12 @@ 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)
|
||||||
|
{
|
||||||
|
ContinuousShuffle_AddToQueueRandom();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int AddedSongs = 0;
|
int AddedSongs = 0;
|
||||||
NumberAddedSongs.Text = AddedSongs.ToString();
|
NumberAddedSongs.Text = AddedSongs.ToString();
|
||||||
SearchStatus.Visibility = Visibility.Visible;
|
SearchStatus.Visibility = Visibility.Visible;
|
||||||
@ -55,17 +59,32 @@ namespace unison
|
|||||||
if (Genre.Items.Count == 0)
|
if (Genre.Items.Count == 0)
|
||||||
{
|
{
|
||||||
_mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
_mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
||||||
Genre.Items.Add("");
|
|
||||||
List<string> Response = await _mpd.SafelySendCommandAsync(new ListCommand(MpdTags.Genre, null, null));
|
List<string> Response = await _mpd.SafelySendCommandAsync(new ListCommand(MpdTags.Genre, null, null));
|
||||||
foreach (var genre in Response)
|
|
||||||
Genre.Items.Add(genre);
|
if (Response.Count > 0)
|
||||||
|
{
|
||||||
|
Genre.Items.Add("");
|
||||||
|
foreach (var genre in Response)
|
||||||
|
Genre.Items.Add(genre);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void ListFolder()
|
public async void ListFolder()
|
||||||
{
|
{
|
||||||
_mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
if (Directory.Items.Count == 0)
|
||||||
//await _mpd.SafelySendCommandAsync(new )
|
{
|
||||||
|
_mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
||||||
|
List<string> Response = await _mpd.SafelySendCommandAsync(new ListFilesCommand());
|
||||||
|
|
||||||
|
if (Response.Count > 0)
|
||||||
|
{
|
||||||
|
Directory.Items.Add("");
|
||||||
|
for (int i = 0; i < Response.Count; i++)
|
||||||
|
if (i % 2 != 1)
|
||||||
|
Directory.Items.Add(Response[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Closing(object sender, CancelEventArgs e)
|
private void Window_Closing(object sender, CancelEventArgs e)
|
||||||
@ -97,7 +116,14 @@ namespace unison
|
|||||||
AddToQueueGroup.IsEnabled = false;
|
AddToQueueGroup.IsEnabled = false;
|
||||||
_continuous = true;
|
_continuous = true;
|
||||||
_songList.Clear();
|
_songList.Clear();
|
||||||
await GetSongsFromFilter();
|
if (Song.Text.Length == 0 && Artist.Text.Length == 0 && Album.Text.Length == 0 && Year.Text.Length == 0 && Genre.SelectedIndex == 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*await*/
|
||||||
|
GetSongsFromFilter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -106,8 +132,30 @@ namespace unison
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// search "((title contains ''))" window 38669:38670
|
private async void ContinuousShuffle_AddToQueueRandom()
|
||||||
// listfiles
|
{
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
// generate random number
|
||||||
|
int song = new Random().Next(0, _mpd.GetStats().Songs - 1);
|
||||||
|
|
||||||
|
// query random song
|
||||||
|
CommandList commandList = new CommandList(new IMpcCommand<object>[] { new SearchCommand(MpdTags.Title, "", song, song + 1) });
|
||||||
|
string Response = await _mpd.SafelySendCommandAsync(commandList);
|
||||||
|
|
||||||
|
await Task.Delay(1);
|
||||||
|
if (Response.Length > 0)
|
||||||
|
{
|
||||||
|
// parse song and add it to queue
|
||||||
|
int start = Response.IndexOf("[file, ");
|
||||||
|
int end = Response.IndexOf("],");
|
||||||
|
string filePath = Response.Substring(start + 7, end - (start + 7));
|
||||||
|
_mpd.AddSong(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SearchStatus.Visibility = Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
|
||||||
private async void AddToQueueRandom()
|
private async void AddToQueueRandom()
|
||||||
{
|
{
|
||||||
@ -144,6 +192,7 @@ namespace unison
|
|||||||
private async Task GetSongsFromFilter()
|
private async Task GetSongsFromFilter()
|
||||||
{
|
{
|
||||||
_songList.Clear();
|
_songList.Clear();
|
||||||
|
SongFilterPanel.Visibility = Visibility.Visible;
|
||||||
|
|
||||||
int song = _mpd.GetStats().Songs;
|
int song = _mpd.GetStats().Songs;
|
||||||
|
|
||||||
@ -160,6 +209,13 @@ namespace unison
|
|||||||
// create a list of the file url
|
// create a list of the file url
|
||||||
string[] value = Response.Split(", [file, ");
|
string[] value = Response.Split(", [file, ");
|
||||||
|
|
||||||
|
// there are no song in this filter
|
||||||
|
if (value[0] == "")
|
||||||
|
{
|
||||||
|
SongFilterNumber.Text = _songList.Count.ToString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (string file in value)
|
foreach (string file in value)
|
||||||
{
|
{
|
||||||
int start = 0;
|
int start = 0;
|
||||||
@ -167,6 +223,8 @@ namespace unison
|
|||||||
string filePath = file.Substring(start, end - start);
|
string filePath = file.Substring(start, end - start);
|
||||||
|
|
||||||
_songList.Add(filePath);
|
_songList.Add(filePath);
|
||||||
|
|
||||||
|
SongFilterNumber.Text = _songList.Count.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove characters from first file
|
// remove characters from first file
|
||||||
@ -176,8 +234,8 @@ namespace unison
|
|||||||
SongFilterNumber.Text = _songList.Count.ToString();
|
SongFilterNumber.Text = _songList.Count.ToString();
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
foreach (var a in _songList)
|
//foreach (var a in _songList)
|
||||||
Debug.WriteLine(a);
|
// Debug.WriteLine(a);
|
||||||
Debug.WriteLine("number of songs found: " + _songList.Count);
|
Debug.WriteLine("number of songs found: " + _songList.Count);
|
||||||
Debug.WriteLine("number of songs requested: " + int.Parse(SongNumber.Text));
|
Debug.WriteLine("number of songs requested: " + int.Parse(SongNumber.Text));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user