Browse Source

优化语音播放

master
胡超1 1 year ago
parent
commit
fb172d3848
  1. 28
      CPF_Cef/Common/ChunkedUpload.cs
  2. 4
      CPF_Cef/FrmMain.cs
  3. 62
      CPF_Cef/MainModel.cs

28
CPF_Cef/Common/ChunkedUpload.cs

@ -9,6 +9,7 @@ using System.Globalization;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace AksWebBrowser.Common namespace AksWebBrowser.Common
@ -761,5 +762,32 @@ namespace AksWebBrowser.Common
ServicePointManager.DefaultConnectionLimit = 1000; ServicePointManager.DefaultConnectionLimit = 1000;
ServicePointManager.Expect100Continue = false; ServicePointManager.Expect100Continue = false;
} }
public static string NumberToChinese(int number)
{
string[] chineseNumbers = new string[] { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" };
string[] chineseUnits = new string[] { "", "十", "百", "千", "万" };
string result = "";
int unitPlace = 0;
if (number == 0)
{
return chineseNumbers[0];
}
while (number > 0)
{
int part = number % 10;
if (part != 0 || (part == 0 && result.Length > 0 && result[0] != '零'))
{
result = string.Format("{0}{1}{2}", chineseNumbers[part], chineseUnits[unitPlace], result);
}
number /= 10;
unitPlace++;
}
return result;
}
} }
} }

4
CPF_Cef/FrmMain.cs

@ -81,9 +81,9 @@ namespace AksWebBrowser
//浏览器大小 //浏览器大小
Parame.webBrowser.Width = w; Parame.webBrowser.Width = w;
Parame.webBrowser.Height = h; Parame.webBrowser.Height = h;
Parame.webBrowser.Url = "http://127.0.0.1:8096/#/main-out"; //Parame.webBrowser.Url = "http://127.0.0.1:8096/#/main-out";
//Parame.webBrowser.Url = "http://192.168.0.232:8848/html/index.html"; //Parame.webBrowser.Url = "http://192.168.0.232:8848/html/index.html";
//Parame.webBrowser.Url = "http://192.168.0.34:8078/#/main-out"; Parame.webBrowser.Url = "http://192.168.0.34:8078/#/main-out";
//Parame.webBrowser.Url = Application.StartupPath + @"\html\index.html"; //Parame.webBrowser.Url = Application.StartupPath + @"\html\index.html";
//开发者工具暂时只能支持Windows //开发者工具暂时只能支持Windows
//webBrowser.ShowDev(); //webBrowser.ShowDev();

62
CPF_Cef/MainModel.cs

@ -400,11 +400,8 @@ namespace AksWebBrowser
else else
{ {
if (ispaye) if (ispaye)
{
Task.Run(() =>
{ {
Task.Run(() => { string command = $"pkill sox"; ShllCommad(command); }); Task.Run(() => { string command = $"pkill sox"; ShllCommad(command); });
});
string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "停止播放成功" + "\"}"; string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "停止播放成功" + "\"}";
SubmitLogs(result, "payleText"); SubmitLogs(result, "payleText");
return result; return result;
@ -1011,11 +1008,8 @@ namespace AksWebBrowser
else else
{ {
if (ispaly) if (ispaly)
{
Task.Run(() =>
{ {
Task.Run(() => { string command = $"pkill sox"; ShllCommad(command); }); Task.Run(() => { string command = $"pkill sox"; ShllCommad(command); });
});
string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "停止播放成功" + "\"}"; string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"data\":\"" + "停止播放成功" + "\"}";
SubmitLogs(result, "PalyFile"); SubmitLogs(result, "PalyFile");
return result; return result;
@ -1024,37 +1018,33 @@ namespace AksWebBrowser
{ {
Task.Run(() => Task.Run(() =>
{ {
Task.Run(() => string command = $"pkill sox"; ShllCommad(command);
{ //Uri uri = new Uri(url);
Task.Run(() => { string command = $"pkill sox"; ShllCommad(command); }); ////返回 123.xlsx
}); //var filename = HttpUtility.UrlDecode(uri.Segments.Last());
Uri uri = new Uri(url); ////获取文件后缀
//返回 123.xlsx //string ext = System.IO.Path.GetExtension(filename);
var filename = HttpUtility.UrlDecode(uri.Segments.Last()); //DateTime dateTime = DateTime.Now;
//获取文件后缀 //string time = DateTime.Now.ToString(
string ext = System.IO.Path.GetExtension(filename); // "yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
DateTime dateTime = DateTime.Now; //string dirpath = Utils.getSystemPaht() + @"/wwwroot/WaveOutFile";
string time = DateTime.Now.ToString( //if (!Directory.Exists(dirpath))
"yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); //{
string dirpath = Utils.getSystemPaht() + @"/wwwroot/WaveOutFile"; // Directory.CreateDirectory(dirpath);
if (!Directory.Exists(dirpath)) //}
{ //string path = dirpath + @"/" + time + ext;
Directory.CreateDirectory(dirpath); //WebRequest request = WebRequest.Create(url);
} //WebResponse response = request.GetResponse();
string path = dirpath + @"/" + time + ext; //using (Stream stream = response.GetResponseStream())
WebRequest request = WebRequest.Create(url); //{
WebResponse response = request.GetResponse(); // using (FileStream fileStream = new FileStream(path, FileMode.Create))
using (Stream stream = response.GetResponseStream()) // {
{ // stream.CopyTo(fileStream);
using (FileStream fileStream = new FileStream(path, FileMode.Create)) // }
{ //}
stream.CopyTo(fileStream); //response.Close();
}
}
response.Close();
//开始播放 //开始播放
string command = $"sox {path} -d"; command = $"sox {url} -d";
ShllCommad(command); ShllCommad(command);
//AutoAudio(ispaly, path); //AutoAudio(ispaly, path);
}); });

Loading…
Cancel
Save