Shuffle: Add clear queue and play queue button
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@ -34,8 +35,9 @@ namespace unison
|
|||||||
|
|
||||||
SongList.Clear();
|
SongList.Clear();
|
||||||
|
|
||||||
int song = _mpd.GetStats().Songs;
|
int songTotal = _mpd.GetStats().Songs;
|
||||||
IEnumerable<IMpdFile> response = await _mpd.SafelySendCommandAsync(new SearchCommand(filter, 0, song + 1));
|
|
||||||
|
IEnumerable<IMpdFile> response = await _mpd.SafelySendCommandAsync(new SearchCommand(filter, 0, songTotal + 1));
|
||||||
foreach (IMpdFile file in response)
|
foreach (IMpdFile file in response)
|
||||||
SongList.Add(file.Path);
|
SongList.Add(file.Path);
|
||||||
}
|
}
|
||||||
@ -45,7 +47,7 @@ namespace unison
|
|||||||
if (token.IsCancellationRequested)
|
if (token.IsCancellationRequested)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int AddedSongs = 0;
|
int addedSongs = 0;
|
||||||
|
|
||||||
var commandList = new CommandList();
|
var commandList = new CommandList();
|
||||||
int songTotal = _mpd.GetStats().Songs;
|
int songTotal = _mpd.GetStats().Songs;
|
||||||
@ -54,13 +56,13 @@ namespace unison
|
|||||||
{
|
{
|
||||||
int song = new Random().Next(0, songTotal - 1);
|
int song = new Random().Next(0, songTotal - 1);
|
||||||
commandList.Add(new SearchAddCommand(new FilterTag(MpdTags.Title, "", FilterOperator.Contains), song, song + 1));
|
commandList.Add(new SearchAddCommand(new FilterTag(MpdTags.Title, "", FilterOperator.Contains), song, song + 1));
|
||||||
AddedSongs++;
|
addedSongs++;
|
||||||
|
|
||||||
// play if stopped or unknown state (no queue managing at the moment, so mandatory)
|
|
||||||
if (i == 0 && (_mpd.GetStatus().State != MpdState.Play && _mpd.GetStatus().State != MpdState.Pause))
|
|
||||||
commandList.Add(new PlayCommand(0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// play if stopped or unknown state (no queue managing at the moment, so mandatory)
|
||||||
|
if ((_mpd.GetStatus().State != MpdState.Play && _mpd.GetStatus().State != MpdState.Pause))
|
||||||
|
commandList.Add(new PlayCommand(0));
|
||||||
|
|
||||||
await _mpd.SafelySendCommandAsync(commandList);
|
await _mpd.SafelySendCommandAsync(commandList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
|||||||
MIT License Copyright (c) 2023 Théo Marchal
|
MIT License Copyright (c) 2025 Théo Marchal
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
27
Resources/Resources.Designer.cs
generated
27
Resources/Resources.Designer.cs
generated
@ -60,6 +60,15 @@ namespace unison.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Clear queue.
|
||||||
|
/// </summary>
|
||||||
|
public static string Clear_Queue {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Clear_Queue", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Database.
|
/// Looks up a localized string similar to Database.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -213,6 +222,24 @@ namespace unison.Resources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Play queue.
|
||||||
|
/// </summary>
|
||||||
|
public static string Play_Queue {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Play_Queue", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Queue management.
|
||||||
|
/// </summary>
|
||||||
|
public static string Queue_Management {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Queue_Management", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Country.
|
/// Looks up a localized string similar to Country.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -117,6 +117,9 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<data name="Clear_Queue" xml:space="preserve">
|
||||||
|
<value>Borrar cola</value>
|
||||||
|
</data>
|
||||||
<data name="Database" xml:space="preserve">
|
<data name="Database" xml:space="preserve">
|
||||||
<value>Base de datos</value>
|
<value>Base de datos</value>
|
||||||
</data>
|
</data>
|
||||||
@ -168,6 +171,12 @@
|
|||||||
<data name="Operator_IsNot" xml:space="preserve">
|
<data name="Operator_IsNot" xml:space="preserve">
|
||||||
<value>no es</value>
|
<value>no es</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Play_Queue" xml:space="preserve">
|
||||||
|
<value>Reproducir cola</value>
|
||||||
|
</data>
|
||||||
|
<data name="Queue_Management" xml:space="preserve">
|
||||||
|
<value>Gestión de cola</value>
|
||||||
|
</data>
|
||||||
<data name="Radios" xml:space="preserve">
|
<data name="Radios" xml:space="preserve">
|
||||||
<value>Radios</value>
|
<value>Radios</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -117,6 +117,9 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<data name="Clear_Queue" xml:space="preserve">
|
||||||
|
<value>Effacer la file</value>
|
||||||
|
</data>
|
||||||
<data name="Database" xml:space="preserve">
|
<data name="Database" xml:space="preserve">
|
||||||
<value>Base de donnée</value>
|
<value>Base de donnée</value>
|
||||||
</data>
|
</data>
|
||||||
@ -168,6 +171,12 @@
|
|||||||
<data name="Operator_IsNot" xml:space="preserve">
|
<data name="Operator_IsNot" xml:space="preserve">
|
||||||
<value>n'est pas</value>
|
<value>n'est pas</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Play_Queue" xml:space="preserve">
|
||||||
|
<value>Jouer la file</value>
|
||||||
|
</data>
|
||||||
|
<data name="Queue_Management" xml:space="preserve">
|
||||||
|
<value>Gestion de file</value>
|
||||||
|
</data>
|
||||||
<data name="Radios" xml:space="preserve">
|
<data name="Radios" xml:space="preserve">
|
||||||
<value>Radios</value>
|
<value>Radios</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -117,6 +117,9 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<data name="Clear_Queue" xml:space="preserve">
|
||||||
|
<value>Clear queue</value>
|
||||||
|
</data>
|
||||||
<data name="Database" xml:space="preserve">
|
<data name="Database" xml:space="preserve">
|
||||||
<value>Database</value>
|
<value>Database</value>
|
||||||
</data>
|
</data>
|
||||||
@ -168,6 +171,12 @@
|
|||||||
<data name="Operator_IsNot" xml:space="preserve">
|
<data name="Operator_IsNot" xml:space="preserve">
|
||||||
<value>is not</value>
|
<value>is not</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Play_Queue" xml:space="preserve">
|
||||||
|
<value>Play queue</value>
|
||||||
|
</data>
|
||||||
|
<data name="Queue_Management" xml:space="preserve">
|
||||||
|
<value>Queue management</value>
|
||||||
|
</data>
|
||||||
<data name="Radios" xml:space="preserve">
|
<data name="Radios" xml:space="preserve">
|
||||||
<value>Radios</value>
|
<value>Radios</value>
|
||||||
</data>
|
</data>
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
<GroupBox.Header>
|
<GroupBox.Header>
|
||||||
<TextBlock>
|
<TextBlock>
|
||||||
<emoji:EmojiInline Text="➕"/>
|
<emoji:EmojiInline Text="➕"/>
|
||||||
<Run Text="{x:Static properties:Resources.Shuffle_Queue}"/>
|
<Run Text="{x:Static properties:Resources.Queue_Management}"/>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</GroupBox.Header>
|
</GroupBox.Header>
|
||||||
<StackPanel Orientation="Vertical" Margin="5,5,5,0">
|
<StackPanel Orientation="Vertical" Margin="5,5,5,0">
|
||||||
@ -96,6 +96,11 @@
|
|||||||
</TextBlock>
|
</TextBlock>
|
||||||
<TextBlock x:Name="SearchStatus2" Text="{x:Static properties:Resources.Shuffle_ButtonMessage3}" Margin="3,3,0,0" FontStyle="Italic" Visibility="Collapsed"/>
|
<TextBlock x:Name="SearchStatus2" Text="{x:Static properties:Resources.Shuffle_ButtonMessage3}" Margin="3,3,0,0" FontStyle="Italic" Visibility="Collapsed"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
|
||||||
|
<Button Content="{x:Static properties:Resources.Clear_Queue}" Click="ClearQueue_Clicked" Padding="5, 2" HorizontalAlignment="Left" FocusVisualStyle="{x:Null}"/>
|
||||||
|
<Button Content="{x:Static properties:Resources.Play_Queue}" Click="StartQueue_Clicked" Padding="5, 2" Margin="5, 0" HorizontalAlignment="Left" FocusVisualStyle="{x:Null}"/>
|
||||||
|
</StackPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
|
||||||
|
@ -375,6 +375,16 @@ namespace unison
|
|||||||
AddToQueue();
|
AddToQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ClearQueue_Clicked(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
_mpd.ClearQueue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartQueue_Clicked(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
_mpd.PlayCommand();
|
||||||
|
}
|
||||||
|
|
||||||
public bool GetContinuous()
|
public bool GetContinuous()
|
||||||
{
|
{
|
||||||
return _continuous;
|
return _continuous;
|
||||||
|
Reference in New Issue
Block a user