forked from ddrilling/AsbCloudServer
89 lines
3.1 KiB
C#
89 lines
3.1 KiB
C#
using System;
|
|
using System.Threading;
|
|
|
|
namespace SaubPanelOnlineSender
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(/*string[] args*/)
|
|
{
|
|
Console.Write("player starting\n");
|
|
Console.Write("press `Esc` or `Q` to quit\n");
|
|
Console.Write("press `p` to pause/unpause\n");
|
|
Console.Write("press `s` to stop/start\n");
|
|
|
|
var playerService = new DbPlayerService();
|
|
|
|
playerService.OnProcessUpdate =
|
|
(s, a) => Console.Write($"Sent: {playerService.LastSentDate:G}\n");
|
|
playerService.OnStateUpdate =
|
|
(s, a) => Console.Write($"\nState: {playerService.State}\n");
|
|
playerService.OnError =
|
|
(s, a) =>
|
|
{
|
|
var color = Console.ForegroundColor;
|
|
Console.ForegroundColor = ConsoleColor.Red;
|
|
Console.Write($"ERROR: {a.Message}");
|
|
Console.ForegroundColor = color;
|
|
Console.Write("\n");
|
|
};
|
|
|
|
playerService.Start();
|
|
|
|
if (Console.IsInputRedirected)
|
|
{
|
|
while (true)
|
|
Thread.Sleep(1000);
|
|
}
|
|
else
|
|
{
|
|
while (true)
|
|
{
|
|
if (Console.KeyAvailable)
|
|
{
|
|
var key = Console.ReadKey().Key;
|
|
if ((key == ConsoleKey.Escape) ||
|
|
(key == ConsoleKey.Q))
|
|
break;
|
|
|
|
if (key == ConsoleKey.P)
|
|
{
|
|
switch (playerService.State)
|
|
{
|
|
case DbPlayerServiceState.Paused:
|
|
case DbPlayerServiceState.Working:
|
|
playerService.Pause();
|
|
break;
|
|
case DbPlayerServiceState.Unaviable:
|
|
case DbPlayerServiceState.Stopped:
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (key == ConsoleKey.S)
|
|
{
|
|
switch (playerService.State)
|
|
{
|
|
case DbPlayerServiceState.Working:
|
|
playerService.Stop();
|
|
break;
|
|
case DbPlayerServiceState.Stopped:
|
|
playerService.Start();
|
|
break;
|
|
case DbPlayerServiceState.Unaviable:
|
|
case DbPlayerServiceState.Paused:
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
Thread.Sleep(200);
|
|
}
|
|
}
|
|
playerService.Stop();
|
|
}
|
|
}
|
|
}
|