From 5b61b5915ff4c0a3defe6b0799dd88b1e5191ab0 Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Tue, 14 May 2019 19:19:13 +0800 Subject: [PATCH] update --- .../SingalDemo/Controllers/HomeController.cs | 2 +- .../IoT/IoTServices/SingalDemo/OmxPlayer.cs | 5 ++-- .../IoT/IoTServices/SingalDemo/Startup.cs | 16 ++++++----- .../IoTServices/SingalDemo/wwwroot/index.html | 28 ++++++++++++++----- .../SingalDemo/wwwroot/start.desktop | 12 ++++++++ 5 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 projects/IoT/IoTServices/SingalDemo/wwwroot/start.desktop diff --git a/projects/IoT/IoTServices/SingalDemo/Controllers/HomeController.cs b/projects/IoT/IoTServices/SingalDemo/Controllers/HomeController.cs index 95a2e9d5..5c30c8b2 100644 --- a/projects/IoT/IoTServices/SingalDemo/Controllers/HomeController.cs +++ b/projects/IoT/IoTServices/SingalDemo/Controllers/HomeController.cs @@ -22,7 +22,7 @@ namespace SingalDemo.Controllers return View(); } - public IActionResult Command(string command, string args, string player = "web") + public IActionResult Command(string command, string args, string player = "omx") { try { diff --git a/projects/IoT/IoTServices/SingalDemo/OmxPlayer.cs b/projects/IoT/IoTServices/SingalDemo/OmxPlayer.cs index b3ac0eef..f72f1cf9 100644 --- a/projects/IoT/IoTServices/SingalDemo/OmxPlayer.cs +++ b/projects/IoT/IoTServices/SingalDemo/OmxPlayer.cs @@ -12,7 +12,7 @@ namespace SingalDemo { lock (lockObject) { - var args = $"-r -o local {file}"; + var args = $"-o local --loop {file}"; if (Player != null && !Player.HasExited && Player.StartInfo.Arguments == args) { Player.StandardInput.Write('p'); @@ -35,7 +35,7 @@ namespace SingalDemo { StartInfo = new ProcessStartInfo { - FileName = "omxplayer", + FileName = "omxplayer.bin", Arguments = args, RedirectStandardInput = true } @@ -53,6 +53,7 @@ namespace SingalDemo { Player.StandardInput.Write('q'); Player.Kill(); + Process.Start("bash", "-c \"xrefresh -display :0\""); } } catch (Exception ex) diff --git a/projects/IoT/IoTServices/SingalDemo/Startup.cs b/projects/IoT/IoTServices/SingalDemo/Startup.cs index f8a9c7ba..b17db10b 100644 --- a/projects/IoT/IoTServices/SingalDemo/Startup.cs +++ b/projects/IoT/IoTServices/SingalDemo/Startup.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -23,7 +18,14 @@ namespace SingalDemo // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddCors(); + services.AddCors(options => options.AddPolicy("CorsPolicy", + builder => + { + builder.SetIsOriginAllowed(o => true) + .AllowAnyMethod() + .AllowAnyHeader() + .AllowCredentials(); + })); services.AddSignalR(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); } @@ -41,7 +43,7 @@ namespace SingalDemo } app.UseStaticFiles(); - app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); + app.UseCors("CorsPolicy"); app.UseSignalR(routes => { routes.MapHub("/hub", o => diff --git a/projects/IoT/IoTServices/SingalDemo/wwwroot/index.html b/projects/IoT/IoTServices/SingalDemo/wwwroot/index.html index 4fd321b0..72e671b5 100644 --- a/projects/IoT/IoTServices/SingalDemo/wwwroot/index.html +++ b/projects/IoT/IoTServices/SingalDemo/wwwroot/index.html @@ -69,7 +69,7 @@ - +
@@ -82,8 +82,10 @@
- +