Compare commits
No commits in common. "c93a9a326ed17f066abdaa1307818e29dc875fb5" and "4c71d6a6e06162faa9b80dacbee75555c473dff0" have entirely different histories.
c93a9a326e
...
4c71d6a6e0
@ -497,23 +497,21 @@ namespace unison
|
||||
|
||||
public async void QueryStats()
|
||||
{
|
||||
Dictionary<string, string> Response = await SafelySendCommandAsync(new StatsCommand());
|
||||
if (Response == null)
|
||||
return;
|
||||
Dictionary<string, string> response = await SafelySendCommandAsync(new StatsCommand());
|
||||
|
||||
_stats.Songs = int.Parse(Response["songs"]);
|
||||
_stats.Albums = int.Parse(Response["albums"]);
|
||||
_stats.Artists = int.Parse(Response["artists"]);
|
||||
_stats.Songs = int.Parse(response["songs"]);
|
||||
_stats.Albums = int.Parse(response["albums"]);
|
||||
_stats.Artists = int.Parse(response["artists"]);
|
||||
|
||||
TimeSpan time;
|
||||
time = TimeSpan.FromSeconds(int.Parse(Response["uptime"]));
|
||||
time = TimeSpan.FromSeconds(int.Parse(response["uptime"]));
|
||||
_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");
|
||||
time = TimeSpan.FromSeconds(int.Parse(Response["playtime"]));
|
||||
time = TimeSpan.FromSeconds(int.Parse(response["playtime"]));
|
||||
_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");
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,6 @@ namespace unison
|
||||
Connection.Text = $"{Properties.Settings.Default.mpd_host}:{Properties.Settings.Default.mpd_port}";
|
||||
|
||||
_shuffleWin.ListGenre();
|
||||
_shuffleWin.ListFolder();
|
||||
}
|
||||
|
||||
public async void OnSongChanged(object sender, EventArgs e)
|
||||
|
@ -57,8 +57,8 @@
|
||||
<Grid>
|
||||
<StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBox x:Name="VolumeOffset" TextWrapping="Wrap" Width="25" PreviewTextInput="NumberValidationTextBox" Margin="0,2,0,0"/>
|
||||
<TextBlock Text="{x:Static properties:Resources.Settings_VolumeOffset}" TextWrapping="Wrap" Margin="5,2,0,0"/>
|
||||
<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="8,2,0,0"/>
|
||||
</StackPanel>
|
||||
<Grid MinWidth="300" Margin="0,5,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
@ -137,11 +137,7 @@
|
||||
</GroupBox.Header>
|
||||
<Grid MaxWidth="500">
|
||||
<StackPanel>
|
||||
<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">
|
||||
<TextBlock TextWrapping="Wrap">
|
||||
<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 FontWeight="Bold">Continuous shuffle</Run><LineBreak/>
|
||||
|
@ -22,37 +22,31 @@
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Text="Song" Margin="0,0,0,2"/>
|
||||
<TextBox x:Name="Song" Width="240" Margin="5,0,0,0"/>
|
||||
<TextBox x:Name="Song" Width="240"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Vertical" Margin="20,0,0,0">
|
||||
<TextBlock Text="Artist" Margin="0,0,0,2"/>
|
||||
<TextBox x:Name="Artist" Width="240" Margin="5,0,0,0"/>
|
||||
<TextBox x:Name="Artist" Width="240"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Text="Album" Margin="0,0,0,2"/>
|
||||
<TextBox x:Name="Album" Width="240" Margin="5,0,0,0"/>
|
||||
<TextBox x:Name="Album" Width="240"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Vertical" Margin="20,0,0,0">
|
||||
<TextBlock Text="Year" Margin="0,0,0,2"/>
|
||||
<TextBox x:Name="Year" Width="240" Margin="5,0,0,0"/>
|
||||
<TextBox x:Name="Year" Width="240"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="0,5,0,5">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<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"/>
|
||||
</StackPanel>
|
||||
<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}"/>
|
||||
<Button Content="Reset" Click="Reset_Clicked" Padding="5, 2" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="20,0,0,0" FocusVisualStyle="{x:Null}"/>
|
||||
</StackPanel>
|
||||
<StackPanel x:Name="SongFilterPanel" Margin="0,5,0,0" Visibility="Collapsed">
|
||||
<TextBlock>
|
||||
|
@ -10,6 +10,8 @@ using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
|
||||
// https://mpd.readthedocs.io/en/stable/protocol.html#binary
|
||||
|
||||
namespace unison
|
||||
{
|
||||
public partial class Shuffle : Window
|
||||
@ -31,12 +33,6 @@ namespace unison
|
||||
|
||||
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;
|
||||
NumberAddedSongs.Text = AddedSongs.ToString();
|
||||
SearchStatus.Visibility = Visibility.Visible;
|
||||
@ -59,32 +55,17 @@ namespace unison
|
||||
if (Genre.Items.Count == 0)
|
||||
{
|
||||
_mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
||||
Genre.Items.Add("");
|
||||
List<string> Response = await _mpd.SafelySendCommandAsync(new ListCommand(MpdTags.Genre, null, null));
|
||||
|
||||
if (Response.Count > 0)
|
||||
{
|
||||
Genre.Items.Add("");
|
||||
foreach (var genre in Response)
|
||||
Genre.Items.Add(genre);
|
||||
}
|
||||
foreach (var genre in Response)
|
||||
Genre.Items.Add(genre);
|
||||
}
|
||||
}
|
||||
|
||||
public async void ListFolder()
|
||||
{
|
||||
if (Directory.Items.Count == 0)
|
||||
{
|
||||
_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]);
|
||||
}
|
||||
}
|
||||
_mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
||||
//await _mpd.SafelySendCommandAsync(new )
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, CancelEventArgs e)
|
||||
@ -116,14 +97,7 @@ namespace unison
|
||||
AddToQueueGroup.IsEnabled = false;
|
||||
_continuous = true;
|
||||
_songList.Clear();
|
||||
if (Song.Text.Length == 0 && Artist.Text.Length == 0 && Album.Text.Length == 0 && Year.Text.Length == 0 && Genre.SelectedIndex == 0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
/*await*/
|
||||
GetSongsFromFilter();
|
||||
}
|
||||
await GetSongsFromFilter();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -132,30 +106,8 @@ namespace unison
|
||||
}
|
||||
}
|
||||
|
||||
private async void ContinuousShuffle_AddToQueueRandom()
|
||||
{
|
||||
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;
|
||||
}
|
||||
// search "((title contains ''))" window 38669:38670
|
||||
// listfiles
|
||||
|
||||
private async void AddToQueueRandom()
|
||||
{
|
||||
@ -192,7 +144,6 @@ namespace unison
|
||||
private async Task GetSongsFromFilter()
|
||||
{
|
||||
_songList.Clear();
|
||||
SongFilterPanel.Visibility = Visibility.Visible;
|
||||
|
||||
int song = _mpd.GetStats().Songs;
|
||||
|
||||
@ -209,13 +160,6 @@ namespace unison
|
||||
// create a list of the file url
|
||||
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)
|
||||
{
|
||||
int start = 0;
|
||||
@ -223,8 +167,6 @@ namespace unison
|
||||
string filePath = file.Substring(start, end - start);
|
||||
|
||||
_songList.Add(filePath);
|
||||
|
||||
SongFilterNumber.Text = _songList.Count.ToString();
|
||||
}
|
||||
|
||||
// remove characters from first file
|
||||
@ -234,8 +176,8 @@ namespace unison
|
||||
SongFilterNumber.Text = _songList.Count.ToString();
|
||||
|
||||
// DEBUG
|
||||
//foreach (var a in _songList)
|
||||
// Debug.WriteLine(a);
|
||||
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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user