2016-12-02 14:19:18 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using LibMpc;
|
|
|
|
|
|
|
|
|
|
namespace LibMpcApp
|
|
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
var mpc = new Mpc(new IPEndPoint(IPAddress.Loopback, 6600));
|
|
|
|
|
|
|
|
|
|
var connected = mpc.ConnectAsync().GetAwaiter().GetResult();
|
|
|
|
|
if (connected)
|
|
|
|
|
{
|
2016-12-02 14:41:52 +00:00
|
|
|
|
Console.WriteLine("Connected to MPD.");
|
2016-12-02 14:19:18 +00:00
|
|
|
|
StartReadCommands(mpc);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-12-02 14:41:52 +00:00
|
|
|
|
Console.WriteLine("Could not connect to MPD.");
|
2016-12-02 14:19:18 +00:00
|
|
|
|
}
|
2016-12-02 14:41:52 +00:00
|
|
|
|
|
|
|
|
|
mpc.DisconnectAsync().GetAwaiter().GetResult();
|
2016-12-02 14:19:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void StartReadCommands(Mpc mpc)
|
|
|
|
|
{
|
2016-12-02 14:41:52 +00:00
|
|
|
|
while(true)
|
|
|
|
|
{
|
|
|
|
|
Console.Write("Command: ");
|
|
|
|
|
var command = Console.ReadLine();
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(command))
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-02 14:19:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|