Snapcast port and auto start working
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user