You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.1 KiB
73 lines
2.1 KiB
using System;
|
|
using System.IO;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
namespace SingalDemo.Controllers
|
|
{
|
|
public class HomeController : Controller
|
|
{
|
|
private readonly IHostingEnvironment _env;
|
|
private readonly IHubContext<PageHub> _pageHubContext;
|
|
|
|
public HomeController(IHostingEnvironment env, IHubContext<PageHub> pageHubContext)
|
|
{
|
|
this._env = env;
|
|
this._pageHubContext = pageHubContext;
|
|
}
|
|
|
|
public IActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public IActionResult Command(string command, string args, string player = "web")
|
|
{
|
|
try
|
|
{
|
|
if (player == "web")
|
|
{
|
|
this._pageHubContext.Clients.All.SendAsync("command", command, args);
|
|
}
|
|
else if (player == "omx")
|
|
{
|
|
if (command == "play")
|
|
{
|
|
var file = Path.Combine(this._env.WebRootPath, "upload", $"{args}.mp4");
|
|
OmxPlayer.Play(file);
|
|
}
|
|
else if (command == "pause")
|
|
{
|
|
OmxPlayer.Pause();
|
|
}
|
|
else if (command == "stop")
|
|
{
|
|
OmxPlayer.Stop();
|
|
}
|
|
else if (command == "si")
|
|
{
|
|
OmxPlayer.SI();
|
|
}
|
|
else if (command == "sd")
|
|
{
|
|
OmxPlayer.SD();
|
|
}
|
|
else if (command == "vi")
|
|
{
|
|
OmxPlayer.VI();
|
|
}
|
|
else if (command == "vd")
|
|
{
|
|
OmxPlayer.VD();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return Content(ex.Message);
|
|
}
|
|
return Content("");
|
|
}
|
|
}
|
|
} |