diff --git a/Handlers/SnapcastHandler.cs b/Handlers/SnapcastHandler.cs
index 4313840..f3e4f47 100644
--- a/Handlers/SnapcastHandler.cs
+++ b/Handlers/SnapcastHandler.cs
@@ -1,4 +1,6 @@
-using System.Diagnostics;
+using System;
+using System.Diagnostics;
+using System.Windows;
namespace unison
{
@@ -6,20 +8,34 @@ namespace unison
{
private readonly Process _snapcast = new();
public bool Started { get; private set; }
- private string _snapcastVersion = "snapclient_0.25.0-1_win64";
+ private string _snapcastPath;
public SnapcastHandler()
{
+ // wip: this will have to be moved after the mpd connection, later on
+ _snapcastPath = Properties.Settings.Default.snapcast_path;
+ if (Properties.Settings.Default.snapcast_startup)
+ Start();
}
- public void Start(string host)
+ public void Start()
{
if (!Started)
{
- _snapcast.StartInfo.FileName = _snapcastVersion + @"\snapclient.exe";
- _snapcast.StartInfo.Arguments = "--host " + host;
+ _snapcast.StartInfo.FileName = _snapcastPath + @"\snapclient.exe";
+ _snapcast.StartInfo.Arguments = $"--host {Properties.Settings.Default.mpd_host}";
_snapcast.StartInfo.CreateNoWindow = true;
- _snapcast.Start();
+ try
+ {
+ _snapcast.Start();
+ }
+ catch (Exception err)
+ {
+ MessageBox.Show($"[Snapcast error]\nInvalid path: {err.Message}\n\nCurrent path: {_snapcastPath}\nYou can reset it in the settings if needed.",
+ "unison", MessageBoxButton.OK, MessageBoxImage.Error);
+ Trace.WriteLine(err.Message);
+ return;
+ }
Started = true;
}
else
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index b18ba0b..78e8bdf 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -82,5 +82,17 @@ namespace unison.Properties {
this["snapcast_path"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("1704")]
+ public int snapcast_port {
+ get {
+ return ((int)(this["snapcast_port"]));
+ }
+ set {
+ this["snapcast_port"] = value;
+ }
+ }
}
}
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
index a4a83aa..24940ea 100644
--- a/Properties/Settings.settings
+++ b/Properties/Settings.settings
@@ -17,5 +17,8 @@
snapclient_0.25.0-1_win64
+
+ 1704
+
\ No newline at end of file
diff --git a/Views/MainWindow.xaml.cs b/Views/MainWindow.xaml.cs
index 56907ef..bc28e34 100644
--- a/Views/MainWindow.xaml.cs
+++ b/Views/MainWindow.xaml.cs
@@ -205,7 +205,7 @@ namespace unison
{
SnapcastHandler snapcast = (SnapcastHandler)Application.Current.Properties["snapcast"];
if (!snapcast.Started)
- snapcast.Start(_mpd.MpdHost);
+ snapcast.Start();
else
snapcast.Stop();
}
diff --git a/Views/Settings.xaml b/Views/Settings.xaml
index bb35767..5324d3c 100644
--- a/Views/Settings.xaml
+++ b/Views/Settings.xaml
@@ -55,9 +55,11 @@
+
+
-
-
+
+
You can change to your own locally installed version of the Snapcast client with an absolute path.
@@ -148,7 +150,7 @@
-
+
diff --git a/Views/Settings.xaml.cs b/Views/Settings.xaml.cs
index 4e9c3b6..5777c29 100644
--- a/Views/Settings.xaml.cs
+++ b/Views/Settings.xaml.cs
@@ -11,7 +11,8 @@ namespace unison
{
public partial class Settings : Window
{
- private string defaultSnapcast = "snapclient_0.25.0-1_win64";
+ private string defaultSnapcastPath = "snapclient_0.25.0-1_win64";
+ private string defaultSnapcastPort = "1704";
public static string GetVersion => Assembly.GetEntryAssembly().GetCustomAttribute().InformationalVersion;
@@ -45,6 +46,7 @@ namespace unison
MpdPassword.Text = Properties.Settings.Default.mpd_password;
SnapcastStartup.IsChecked = Properties.Settings.Default.snapcast_startup;
SnapcastPath.Text = Properties.Settings.Default.snapcast_path;
+ SnapcastPort.Text = Properties.Settings.Default.snapcast_port.ToString();
}
private void NumberValidationTextBox(object sender, TextCompositionEventArgs e)
@@ -63,7 +65,8 @@ namespace unison
private void SnapcastReset_Clicked(object sender, RoutedEventArgs e)
{
- SnapcastPath.Text = defaultSnapcast;
+ SnapcastPath.Text = defaultSnapcastPath;
+ SnapcastPort.Text = defaultSnapcastPort;
}
private void Window_Closing(object sender, CancelEventArgs e)
@@ -75,6 +78,7 @@ namespace unison
Properties.Settings.Default.mpd_password = MpdPassword.Text;
Properties.Settings.Default.snapcast_startup = (bool)SnapcastStartup.IsChecked;
Properties.Settings.Default.snapcast_path = SnapcastPath.Text;
+ Properties.Settings.Default.snapcast_port = int.Parse(SnapcastPort.Text);
Properties.Settings.Default.Save();
WindowState = WindowState.Minimized;