調整 手機點歌 歌曲名稱不會顯示 20250721
This commit is contained in:
parent
e532e26b54
commit
e1d7653a1a
@ -22,10 +22,20 @@ namespace DBObj
|
||||
basic=new(songNumber,song,songSimplified,filename,humanVoice);
|
||||
A= new Artist(artistA, artistASimplified);
|
||||
if(artistB!=null){
|
||||
B= new Artist(artistB, artistBSimplified);
|
||||
B = new Artist(artistB, artistBSimplified);
|
||||
}
|
||||
isPublicSong = false;
|
||||
}
|
||||
public SongData(SongData value,PlayState s){
|
||||
basic = value.getBasic();
|
||||
A = value.getA();
|
||||
B = value.getB();
|
||||
state =s;
|
||||
}
|
||||
public Song getBasic() => basic;
|
||||
public Artist getA() => A;
|
||||
public Artist getB() => B;
|
||||
|
||||
public string getNumber() {return basic.getNumber();}
|
||||
public string getName(bool IsSimplified=false) { return basic.getName(IsSimplified); }
|
||||
public string getName() { return basic.getName();}
|
||||
@ -79,15 +89,7 @@ namespace DBObj
|
||||
return c;
|
||||
}
|
||||
public string GetStateTxt(bool IsSimplified){
|
||||
string txt = string.Empty;
|
||||
if (state == PlayState.Played) {
|
||||
txt = IsSimplified ? "(播毕)" : "(播畢)";
|
||||
} else if (state == PlayState.Playing) {
|
||||
txt = IsSimplified ? "(播放中)" : "(播放中)";
|
||||
} else if (state == PlayState.InsertPlayback) {
|
||||
txt = IsSimplified ? "(插播)" : "(插播)";
|
||||
}
|
||||
return txt;
|
||||
return (state==PlayState.NotPlayed)?"":$"({state.GetDescription(IsSimplified)})";
|
||||
}
|
||||
public void SetState(PlayState s) => state = s;
|
||||
|
||||
|
@ -68,14 +68,13 @@ namespace DBObj
|
||||
|
||||
public static void Add(SongData song)
|
||||
{
|
||||
not_played.Add(song);
|
||||
not_played.Add(new SongData(song,PlayState.NotPlayed));
|
||||
// PrimaryForm.Instance.AddSongCount(songData.Number);
|
||||
chkCut();
|
||||
}
|
||||
public static void Insert(SongData song)
|
||||
{
|
||||
song.SetState(PlayState.InsertPlayback);
|
||||
not_played.Insert(0, song);
|
||||
not_played.Insert(0, new SongData(song,PlayState.InsertPlayback));
|
||||
chkCut();
|
||||
}
|
||||
private static void chkCut()
|
||||
|
19
EnumExtensions.cs
Normal file
19
EnumExtensions.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
public static class EnumExtensions
|
||||
{
|
||||
public static string GetDescription(this Enum value, bool isSimplified = false)
|
||||
{
|
||||
var field = value.GetType().GetField(value.ToString());
|
||||
|
||||
var attr = field?.GetCustomAttribute<LocalizedDescriptionAttribute>();
|
||||
if (attr != null)
|
||||
return isSimplified ? attr.Simplified : attr.Traditional;
|
||||
|
||||
return value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ using ActionString = System.Action<string>; // 现在可以在代码中使用 Ac
|
||||
using System.Collections.Concurrent;
|
||||
using DBObj;
|
||||
using OverlayFormObj;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
@ -369,8 +370,16 @@ namespace DualScreenDemo
|
||||
searchResults = new List<SongData>();
|
||||
break;
|
||||
}
|
||||
var response = searchResults
|
||||
.Select(song => new
|
||||
{
|
||||
Song = song.getName(),
|
||||
ArtistA =song.getArtist_A(),
|
||||
SongNumber = song.getNumber(),
|
||||
})
|
||||
.ToList();
|
||||
|
||||
await SendJsonResponseAsync(context, searchResults);
|
||||
await SendJsonResponseAsync(context, response);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -532,9 +541,6 @@ namespace DualScreenDemo
|
||||
break;
|
||||
case "male_key":
|
||||
// 执行男调操作
|
||||
//OverlayForm.MainForm.Invoke(new System.Action(() => {
|
||||
// OverlayForm.MainForm.ShowTopRightLabelTime(" 男調 ");
|
||||
//}));
|
||||
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
|
||||
{
|
||||
// 假設 0xA2, 0xC1, 0xA4 是升調的指令
|
||||
@ -552,9 +558,6 @@ namespace DualScreenDemo
|
||||
break;
|
||||
case "female_key":
|
||||
// 执行女调操作
|
||||
//OverlayForm.MainForm.Invoke(new System.Action(() => {
|
||||
// OverlayForm.MainForm.ShowTopRightLabelTime(" 女調 ");
|
||||
//}));
|
||||
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
|
||||
{
|
||||
// 假設 0xA2, 0xC1, 0xA4 是升調的指令
|
||||
@ -579,11 +582,6 @@ namespace DualScreenDemo
|
||||
break;
|
||||
case "lower_key":
|
||||
// 执行降调操作
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() => {
|
||||
OverlayForm.MainForm.ShowTopRightLabelTime("降 1# 調");
|
||||
}));
|
||||
|
||||
// MessageBox.Show("降調功能啟動");
|
||||
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
|
||||
{
|
||||
// 假設 0xA2, 0xC2, 0xA4 是降調的指令
|
||||
@ -598,9 +596,6 @@ namespace DualScreenDemo
|
||||
break;
|
||||
case "standard_key":
|
||||
// 执行标准调操作
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() => {
|
||||
OverlayForm.MainForm.ShowTopRightLabelTime(" 標準調 ");
|
||||
}));
|
||||
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
|
||||
{
|
||||
// 假設 0xA2, 0xC1, 0xA4 是升調的指令
|
||||
@ -615,11 +610,6 @@ namespace DualScreenDemo
|
||||
break;
|
||||
case "raise_key":
|
||||
// 执行升调操作
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() => {
|
||||
OverlayForm.MainForm.ShowTopRightLabelTime("升 1# 調");
|
||||
}));
|
||||
|
||||
// MessageBox.Show("升調功能啟動");
|
||||
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
|
||||
{
|
||||
// 假設 0xA2, 0xC1, 0xA4 是升調的指令
|
||||
@ -670,25 +660,19 @@ namespace DualScreenDemo
|
||||
|
||||
Console.WriteLine("Received order song request: " + requestBody);
|
||||
// 检查 playedSongsHistory 是否存在且不为空
|
||||
var response = new { status = "info", message = "No songs in the played history" };
|
||||
|
||||
// 创建响应数据
|
||||
/*
|
||||
response = new
|
||||
var response = new
|
||||
{
|
||||
playingSongList = PrimaryForm.playedSongsHistory
|
||||
playingSongList = SongList.GetHistory()
|
||||
.Select((song, index) => new
|
||||
{
|
||||
song.Name,
|
||||
song.Artist_A,
|
||||
song.FileName,
|
||||
State = song.GetState() == PlayState.Playing ? "播放中" : "播放完畢"
|
||||
Song=song.getName(),
|
||||
ArtistA=song.getArtist_A(),
|
||||
PlayState = song.GetState().GetDescription()
|
||||
})
|
||||
.ToList(),
|
||||
// 生成播放历史
|
||||
currentSongIndexInHistory = PrimaryForm.currentSongIndexInHistory
|
||||
.ToList()
|
||||
};
|
||||
*/
|
||||
|
||||
jsonResponse = JsonConvert.SerializeObject(response);
|
||||
context.Response.StatusCode = (int)HttpStatusCode.OK;
|
||||
|
||||
@ -716,22 +700,20 @@ namespace DualScreenDemo
|
||||
}
|
||||
|
||||
Console.WriteLine("Received order song request: " + requestBody);
|
||||
|
||||
// 解析 JSON 为 Song 对象
|
||||
var song = JsonConvert.DeserializeObject<SongData>(requestBody);
|
||||
var json = JObject.Parse(requestBody);
|
||||
SongData song =songListManager.SearchSongByNumber(json["SongNumber"]?.ToString());
|
||||
|
||||
if (song != null)
|
||||
{
|
||||
if (song != null) {
|
||||
Console.WriteLine($"Ordering Song: {song.getName()} by {song.getArtist_A()}");
|
||||
|
||||
// 这里可以添加处理逻辑,例如将歌曲加入到播放列表或数据库中
|
||||
SongList.Add(song);
|
||||
|
||||
var response = new { status = "success", message = "Song ordered successfully" };
|
||||
string jsonResponse = JsonConvert.SerializeObject(response);
|
||||
await SendResponseAsync(context, jsonResponse);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||
await SendResponseAsync(context, "{\"status\": \"error\", \"message\": \"Invalid song data\"}");
|
||||
}
|
||||
@ -757,19 +739,17 @@ namespace DualScreenDemo
|
||||
Console.WriteLine("Received insert song request: " + requestBody);
|
||||
|
||||
// 解析 JSON 为 Song 对象
|
||||
var song = JsonConvert.DeserializeObject<SongData>(requestBody);
|
||||
var json = JObject.Parse(requestBody);
|
||||
SongData song =songListManager.SearchSongByNumber(json["SongNumber"]?.ToString());
|
||||
|
||||
if (song != null)
|
||||
{
|
||||
if (song != null){
|
||||
Console.WriteLine($"Inserting Song: {song.getName()} by {song.getArtist_A()}");
|
||||
// 这里可以添加插播歌曲的处理逻辑
|
||||
SongList.Insert(song);
|
||||
var response = new { status = "success", message = "Song inserted successfully" };
|
||||
string jsonResponse = JsonConvert.SerializeObject(response);
|
||||
await SendResponseAsync(context, jsonResponse);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||
await SendResponseAsync(context, "{\"status\": \"error\", \"message\": \"Invalid song data\"}");
|
||||
}
|
||||
@ -1047,9 +1027,9 @@ namespace DualScreenDemo
|
||||
Name = song.getName(),
|
||||
ArtistA =song.getArtist_A(),
|
||||
Number = song.getNumber(),
|
||||
//song.getArtist_A(true),
|
||||
//song.getArtist_B(true),
|
||||
//song.getName(true),
|
||||
ArtistAFull = song.getArtist_A(true),
|
||||
ArtistBFull = song.getArtist_B(true),
|
||||
NameFull = song.getName(true),
|
||||
HumanVoice =song.getHumanVoice(),
|
||||
FileName = song.getFileName()
|
||||
})
|
||||
|
17
LocalizedDescriptionAttribute.cs
Normal file
17
LocalizedDescriptionAttribute.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class LocalizedDescriptionAttribute : Attribute
|
||||
{
|
||||
public string Traditional { get; }
|
||||
public string Simplified { get; }
|
||||
|
||||
public LocalizedDescriptionAttribute(string traditional, string simplified)
|
||||
{
|
||||
Traditional = traditional;
|
||||
Simplified = simplified;
|
||||
}
|
||||
}
|
||||
}
|
27
PlayState.cs
27
PlayState.cs
@ -1,13 +1,26 @@
|
||||
using System.ComponentModel;
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
|
||||
|
||||
public enum PlayState
|
||||
{
|
||||
NotPlayed, // 未播放
|
||||
Playing, // 正在播放
|
||||
Played, // 已播放
|
||||
InsertPlayback, // 插入播放
|
||||
NoFile, // 沒有文件
|
||||
Skipped // 已跳過
|
||||
[LocalizedDescription("", "")]//未播放
|
||||
NotPlayed,
|
||||
|
||||
[LocalizedDescription("播放中", "播放中")]
|
||||
Playing,
|
||||
|
||||
[LocalizedDescription("播畢", "播毕")]
|
||||
Played,
|
||||
|
||||
[LocalizedDescription("插播", "插播")]
|
||||
InsertPlayback,
|
||||
|
||||
[LocalizedDescription("無文件", "无文件")]
|
||||
NoFile,
|
||||
|
||||
[LocalizedDescription("已跳過", "已跳过")]
|
||||
Skipped
|
||||
|
||||
}
|
||||
}
|
@ -1938,19 +1938,14 @@ namespace DualScreenDemo
|
||||
|
||||
private void MaleKeyButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
//verlayForm.MainForm.ShowTopRightLabelTime(" 男調 ");
|
||||
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
|
||||
{
|
||||
|
||||
byte[] commandBytesIncreasePitch1 = new byte[] { 0xA2, 0x7F, 0xA4 };
|
||||
SerialPortManager.mySerialPort.Write(commandBytesIncreasePitch1, 0, commandBytesIncreasePitch1.Length);
|
||||
//OverlayForm.MainForm.HideAllLabels();
|
||||
byte[] commandBytesDecreasePitch = new byte[] { 0xA2, 0xB2, 0xA4 };
|
||||
SerialPortManager.mySerialPort.Write(commandBytesDecreasePitch, 0, commandBytesDecreasePitch.Length);
|
||||
//OverlayForm.MainForm.HideAllLabels();
|
||||
SerialPortManager.mySerialPort.Write(commandBytesDecreasePitch, 0, commandBytesDecreasePitch.Length);
|
||||
//OverlayForm.MainForm.HideAllLabels();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1961,17 +1956,13 @@ namespace DualScreenDemo
|
||||
|
||||
private void FemaleKeyButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
//OverlayForm.MainForm.ShowTopRightLabelTime(" 女調 ");
|
||||
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
|
||||
{
|
||||
byte[] commandBytesIncreasePitch1 = new byte[] { 0xA2, 0x7F, 0xA4 };
|
||||
SerialPortManager.mySerialPort.Write(commandBytesIncreasePitch1, 0, commandBytesIncreasePitch1.Length);
|
||||
//OverlayForm.MainForm.HideAllLabels();
|
||||
byte[] commandBytesIncreasePitch = new byte[] { 0xA2, 0xB1, 0xA4 };
|
||||
SerialPortManager.mySerialPort.Write(commandBytesIncreasePitch, 0, commandBytesIncreasePitch.Length);
|
||||
//OverlayForm.MainForm.HideAllLabels();
|
||||
SerialPortManager.mySerialPort.Write(commandBytesIncreasePitch, 0, commandBytesIncreasePitch.Length);
|
||||
//OverlayForm.MainForm.HideAllLabels();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1982,8 +1973,6 @@ namespace DualScreenDemo
|
||||
|
||||
private void StandardKeyButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OverlayForm.MainForm.ShowTopRightLabelTime(" 標準調 ");
|
||||
|
||||
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
|
||||
{
|
||||
byte[] commandBytesIncreasePitch = new byte[] { 0xA2, 0x7F, 0xA4 };
|
||||
@ -1997,7 +1986,6 @@ namespace DualScreenDemo
|
||||
|
||||
private void PitchUpButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OverlayForm.MainForm.ShowTopRightLabelTime("升 1# 調 ");
|
||||
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
|
||||
{
|
||||
byte[] commandBytesIncreasePitch = new byte[] { 0xA2, 0xB1, 0xA4 };
|
||||
@ -2011,7 +1999,6 @@ namespace DualScreenDemo
|
||||
|
||||
private void PitchDownButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
OverlayForm.MainForm.ShowTopRightLabelTime("降 1# 調 ");
|
||||
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
|
||||
{
|
||||
byte[] commandBytesDecreasePitch = new byte[] { 0xA2, 0xB2, 0xA4 };
|
||||
|
@ -17,7 +17,7 @@ namespace DualScreenDemo
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Console.WriteLine("Server V.1.2.2 202507171805");
|
||||
Console.WriteLine("Server V.1.2.3 202507211300");
|
||||
if (Utils.Env.GetBool("IsCursor", true)) Cursor.Hide();
|
||||
AppDomain.CurrentDomain.ProcessExit += (s, e) => Cursor.Show();
|
||||
//Console.WriteLine("正在與中控取得聯繫...");
|
||||
|
@ -623,8 +623,8 @@ namespace DualScreenDemo
|
||||
if (videoWindowSecondary != null) videoWindowSecondary.put_Visible(OABool.False);
|
||||
|
||||
// 清理並初始化 DirectShow 圖表
|
||||
//RemoveAllFilters(graphBuilderPrimary);
|
||||
//RemoveAllFilters(graphBuilderSecondary);
|
||||
RemoveAllFilters(graphBuilderPrimary);
|
||||
RemoveAllFilters(graphBuilderSecondary);
|
||||
InitializeGraphBuilderPrimary();
|
||||
InitializeGraphBuilderSecondary();
|
||||
|
||||
@ -667,8 +667,8 @@ namespace DualScreenDemo
|
||||
if (videoWindowSecondary != null) videoWindowSecondary.put_Visible(OABool.False); // 隐藏副屏幕窗口,避免闪烁
|
||||
|
||||
// 清理并初始化 DirectShow 图表
|
||||
//RemoveAllFilters(graphBuilderPrimary);
|
||||
//RemoveAllFilters(graphBuilderSecondary);
|
||||
RemoveAllFilters(graphBuilderPrimary);
|
||||
RemoveAllFilters(graphBuilderSecondary);
|
||||
InitializeGraphBuilderPrimary();
|
||||
InitializeGraphBuilderSecondary();
|
||||
|
||||
|
@ -389,8 +389,6 @@
|
||||
Song: row.cells[0].textContent,
|
||||
ArtistA: row.cells[1].textContent,
|
||||
SongNumber: row.cells[2].textContent,
|
||||
SongFilePathHost1: row.cells[3].textContent,
|
||||
SongFilePathHost2: row.cells[4].textContent
|
||||
};
|
||||
|
||||
window.selectedSong = song;
|
||||
@ -543,8 +541,6 @@
|
||||
<td>${song.Song}</td>
|
||||
<td>${song.ArtistA}</td>
|
||||
<td>${song.SongNumber}</td>
|
||||
<td style="display:none;">${song.SongFilePathHost1}</td>
|
||||
<td style="display:none;">${song.SongFilePathHost2}</td>
|
||||
`;
|
||||
row.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
Loading…
x
Reference in New Issue
Block a user