Misc. fixes, added volume offset option
This commit is contained in:
parent
89ddb81840
commit
8896c13442
@ -1,12 +1,6 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Hardcodet.Wpf.TaskbarNotification;
|
using Hardcodet.Wpf.TaskbarNotification;
|
||||||
|
|
||||||
// todo:
|
|
||||||
//
|
|
||||||
// * show mpd version
|
|
||||||
// * change volume offset
|
|
||||||
// * fix window resize (if it still happens?)
|
|
||||||
|
|
||||||
namespace unison
|
namespace unison
|
||||||
{
|
{
|
||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
|
@ -75,11 +75,15 @@ namespace unison
|
|||||||
mpd.Prev();
|
mpd.Prev();
|
||||||
break;
|
break;
|
||||||
case VK_VOLUME_DOWN:
|
case VK_VOLUME_DOWN:
|
||||||
mpd._currentVolume -= 5;
|
mpd._currentVolume -= Properties.Settings.Default.volume_offset;
|
||||||
|
if (mpd._currentVolume < 0)
|
||||||
|
mpd._currentVolume = 0;
|
||||||
mpd.SetVolume(mpd._currentVolume);
|
mpd.SetVolume(mpd._currentVolume);
|
||||||
break;
|
break;
|
||||||
case VK_VOLUME_UP:
|
case VK_VOLUME_UP:
|
||||||
mpd._currentVolume += 5;
|
mpd._currentVolume += Properties.Settings.Default.volume_offset;
|
||||||
|
if (mpd._currentVolume > 100)
|
||||||
|
mpd._currentVolume = 100;
|
||||||
mpd.SetVolume(mpd._currentVolume);
|
mpd.SetVolume(mpd._currentVolume);
|
||||||
break;
|
break;
|
||||||
case VK_MEDIA_PLAY_PAUSE:
|
case VK_MEDIA_PLAY_PAUSE:
|
||||||
@ -93,10 +97,19 @@ namespace unison
|
|||||||
AppWindow.WindowState = WindowState.Normal;
|
AppWindow.WindowState = WindowState.Normal;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (AppWindow.IsActive)
|
||||||
{
|
{
|
||||||
AppWindow.Hide();
|
AppWindow.Hide();
|
||||||
AppWindow.WindowState = WindowState.Minimized;
|
AppWindow.WindowState = WindowState.Minimized;
|
||||||
}
|
}
|
||||||
|
else // not minimized but not in front
|
||||||
|
{
|
||||||
|
AppWindow.Show();
|
||||||
|
AppWindow.Activate();
|
||||||
|
AppWindow.WindowState = WindowState.Normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
handled = true;
|
handled = true;
|
||||||
|
@ -59,7 +59,6 @@ namespace unison
|
|||||||
_elapsedTimer = new System.Timers.Timer(500);
|
_elapsedTimer = new System.Timers.Timer(500);
|
||||||
_elapsedTimer.Elapsed += new System.Timers.ElapsedEventHandler(ElapsedTimer);
|
_elapsedTimer.Elapsed += new System.Timers.ElapsedEventHandler(ElapsedTimer);
|
||||||
|
|
||||||
|
|
||||||
DispatcherTimer timer = new DispatcherTimer();
|
DispatcherTimer timer = new DispatcherTimer();
|
||||||
timer.Interval = TimeSpan.FromSeconds(2);
|
timer.Interval = TimeSpan.FromSeconds(2);
|
||||||
timer.Tick += QueryStatus;
|
timer.Tick += QueryStatus;
|
||||||
@ -228,6 +227,7 @@ namespace unison
|
|||||||
_elapsedTimer.Stop();
|
_elapsedTimer.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_currentSong != null)
|
||||||
await _mpd.MpdQueryAlbumArt(_currentSong.File, false);
|
await _mpd.MpdQueryAlbumArt(_currentSong.File, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,5 +291,10 @@ namespace unison
|
|||||||
{
|
{
|
||||||
return _currentStatus?.MpdState == MPDCtrl.Models.Status.MpdPlayState.Play;
|
return _currentStatus?.MpdState == MPDCtrl.Models.Status.MpdPlayState.Play;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetVersion()
|
||||||
|
{
|
||||||
|
return _mpd.MpdVerText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
Properties/Settings.Designer.cs
generated
12
Properties/Settings.Designer.cs
generated
@ -94,5 +94,17 @@ namespace unison.Properties {
|
|||||||
this["snapcast_port"] = value;
|
this["snapcast_port"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("5")]
|
||||||
|
public int volume_offset {
|
||||||
|
get {
|
||||||
|
return ((int)(this["volume_offset"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["volume_offset"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,8 @@
|
|||||||
<Setting Name="snapcast_port" Type="System.Int32" Scope="User">
|
<Setting Name="snapcast_port" Type="System.Int32" Scope="User">
|
||||||
<Value Profile="(Default)">1704</Value>
|
<Value Profile="(Default)">1704</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="volume_offset" Type="System.Int32" Scope="User">
|
||||||
|
<Value Profile="(Default)">5</Value>
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
@ -9,7 +9,7 @@ namespace unison
|
|||||||
{
|
{
|
||||||
public partial class MainWindow : Window, INotifyPropertyChanged
|
public partial class MainWindow : Window, INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
private readonly Settings SettingsWindow = new Settings();
|
public readonly Settings SettingsWindow = new Settings();
|
||||||
|
|
||||||
private MPDHandler mpd;
|
private MPDHandler mpd;
|
||||||
|
|
||||||
|
@ -34,7 +34,9 @@
|
|||||||
<TextBlock Text="Password" TextWrapping="Wrap" Margin="5,0,0,0"/>
|
<TextBlock Text="Password" TextWrapping="Wrap" Margin="5,0,0,0"/>
|
||||||
<TextBox x:Name="MpdPassword" TextWrapping="Wrap" Width="250" Margin="10,2,0,0"/>
|
<TextBox x:Name="MpdPassword" TextWrapping="Wrap" Width="250" Margin="10,2,0,0"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Button Content="Connect" Margin="0,10,0,0" Width="120" Click="MPDConnect_Clicked"/>
|
|
||||||
|
<TextBlock x:Name="ConnectionStatus" Text="Not connected." TextWrapping="Wrap" Margin="5,10,0,0"/>
|
||||||
|
<Button x:Name="ConnectButton" Content="Connect" Margin="0,10,0,0" Width="120" Click="MPDConnect_Clicked"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
@ -79,7 +81,12 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</GroupBox.Header>
|
</GroupBox.Header>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid MinWidth="220">
|
<StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Text="Volume offset" TextWrapping="Wrap"/>
|
||||||
|
<TextBox x:Name="VolumeOffset" TextWrapping="Wrap" Width="25" PreviewTextInput="NumberValidationTextBox" Margin="8,2,0,0"/>
|
||||||
|
</StackPanel>
|
||||||
|
<Grid MinWidth="220" Margin="0,5,0,0">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition/>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition/>
|
||||||
@ -106,6 +113,7 @@
|
|||||||
<TextBlock Text="ctrl + volume_down" TextWrapping="Wrap" Grid.Column="1" Grid.Row="4" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/>
|
<TextBlock Text="ctrl + volume_down" TextWrapping="Wrap" Grid.Column="1" Grid.Row="4" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/>
|
||||||
<TextBlock Text="ctrl + alt + enter" TextWrapping="Wrap" Grid.Column="1" Grid.Row="5" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/>
|
<TextBlock Text="ctrl + alt + enter" TextWrapping="Wrap" Grid.Column="1" Grid.Row="5" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
@ -50,6 +50,7 @@ namespace unison
|
|||||||
SnapcastStartup.IsChecked = Properties.Settings.Default.snapcast_startup;
|
SnapcastStartup.IsChecked = Properties.Settings.Default.snapcast_startup;
|
||||||
SnapcastPath.Text = Properties.Settings.Default.snapcast_path;
|
SnapcastPath.Text = Properties.Settings.Default.snapcast_path;
|
||||||
SnapcastPort.Text = Properties.Settings.Default.snapcast_port.ToString();
|
SnapcastPort.Text = Properties.Settings.Default.snapcast_port.ToString();
|
||||||
|
VolumeOffset.Text = Properties.Settings.Default.volume_offset.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NumberValidationTextBox(object sender, TextCompositionEventArgs e)
|
private void NumberValidationTextBox(object sender, TextCompositionEventArgs e)
|
||||||
@ -66,11 +67,22 @@ namespace unison
|
|||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateConnectionStatus()
|
||||||
|
{
|
||||||
|
MPDHandler mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
||||||
|
if (mpd._connected)
|
||||||
|
{
|
||||||
|
ConnectionStatus.Text = "Connected to MPD " + mpd.GetVersion() + ".";
|
||||||
|
ConnectButton.IsEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void MPDConnect_Clicked(object sender, RoutedEventArgs e)
|
private void MPDConnect_Clicked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
MPDHandler mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
MPDHandler mpd = (MPDHandler)Application.Current.Properties["mpd"];
|
||||||
//mpd.Connect();
|
mpd.Start();
|
||||||
|
UpdateConnectionStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SnapcastReset_Clicked(object sender, RoutedEventArgs e)
|
private void SnapcastReset_Clicked(object sender, RoutedEventArgs e)
|
||||||
@ -87,6 +99,7 @@ namespace unison
|
|||||||
Properties.Settings.Default.snapcast_startup = (bool)SnapcastStartup.IsChecked;
|
Properties.Settings.Default.snapcast_startup = (bool)SnapcastStartup.IsChecked;
|
||||||
Properties.Settings.Default.snapcast_path = SnapcastPath.Text;
|
Properties.Settings.Default.snapcast_path = SnapcastPath.Text;
|
||||||
Properties.Settings.Default.snapcast_port = int.Parse(SnapcastPort.Text, CultureInfo.InvariantCulture);
|
Properties.Settings.Default.snapcast_port = int.Parse(SnapcastPort.Text, CultureInfo.InvariantCulture);
|
||||||
|
Properties.Settings.Default.volume_offset = int.Parse(VolumeOffset.Text, CultureInfo.InvariantCulture);
|
||||||
Properties.Settings.Default.Save();
|
Properties.Settings.Default.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,12 @@
|
|||||||
<Win32Resource></Win32Resource>
|
<Win32Resource></Win32Resource>
|
||||||
<StartupObject>unison.App</StartupObject>
|
<StartupObject>unison.App</StartupObject>
|
||||||
<Version>0.0.1</Version>
|
<Version>0.0.1</Version>
|
||||||
|
<Company />
|
||||||
|
<Authors>Théo Marchal</Authors>
|
||||||
|
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||||
|
<PackageProjectUrl>https://git.n700.ovh/keb/unison</PackageProjectUrl>
|
||||||
|
<RepositoryUrl>https://git.n700.ovh/keb/unison</RepositoryUrl>
|
||||||
|
<Copyright>Théo Marchal</Copyright>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -21,6 +27,10 @@
|
|||||||
<None Remove="snapclient_0.25.0-1_win64\snapclient.exe" />
|
<None Remove="snapclient_0.25.0-1_win64\snapclient.exe" />
|
||||||
<None Remove="snapclient_0.25.0-1_win64\soxr.dll" />
|
<None Remove="snapclient_0.25.0-1_win64\soxr.dll" />
|
||||||
<None Remove="snapclient_0.25.0-1_win64\vorbis.dll" />
|
<None Remove="snapclient_0.25.0-1_win64\vorbis.dll" />
|
||||||
|
<None Include="LICENSE">
|
||||||
|
<Pack>True</Pack>
|
||||||
|
<PackagePath></PackagePath>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user