2508141752

1.DBConnection參數獲取方式修改
2.歌手VOD選取範圍修正
3.撥放器微調
This commit is contained in:
jasonchenwork 2025-08-14 17:53:56 +08:00
parent a3955b2672
commit c151168159
23 changed files with 71 additions and 22 deletions

10
Env.cs
View File

@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Security;
using DualScreenDemo;
using HeartbeatSender;
namespace Utils
{
@ -26,7 +29,6 @@ namespace Utils
{
KtvPath = path;
Console.WriteLine("找到設定檔:" + configPath);
foreach (var line in File.ReadAllLines(configPath))
{
var trimmed = line.Trim();
@ -58,7 +60,7 @@ namespace Utils
// .ToArray();
return new string[] { @"\\svr01", @"\\svr02" };
}
public static string Get(string key, string fallback = "") =>
@ -94,10 +96,10 @@ namespace Utils
}
public static string GetDBConnection()
{
return $"Server={Get("DBServer", "localhost")};Port={Get("DBPort", "3306")};Database={Get("Database", "test")};User={Get("DBUser", "root")};Password={Get("DBPassword", "")};";
// return $"Server={Get("DBServer", "localhost")};Port={Get("DBPort", "3306")};Database={Get("Database", "test")};User={Get("DBUser", "root")};Password={Get("DBPassword", "")};";
return $"Server={heartbeatSender.DbData["DBServer"]};Port={heartbeatSender.DbData["DBPort"]};Database={heartbeatSender.DbData["Database"]};User={heartbeatSender.DbData["DBUser"]};Password={heartbeatSender.DbData["DBPassword"]};";
}
// 如需支援更多型別可自行擴充GetFloat, GetDouble, GetDateTime 等
}
}

View File

@ -18,11 +18,12 @@ public class heartbeatSender
private string branchName = "";
private string heartbeatDomain = "";
private CancellationTokenSource? cancellationTokenSource;
public static Dictionary<string, string> DbData= new Dictionary<string, string>() ;
public heartbeatSender()
{
this.heartbeatDomain = Utils.Env.Get("HeartBeatUrl", "");
bool loginSuccess = LoginAndGetTokenAsync().GetAwaiter().GetResult();
Console.WriteLine(loginSuccess ? "心跳登入成功" : "心跳登入失敗");
// 在建構子中啟動背景心跳任務
_ = Task.Run(() => StartAsync());
}
@ -77,6 +78,15 @@ public class heartbeatSender
{
token = data.GetProperty("token").GetString()!;
branchName = data.GetProperty("branch_name").GetString()!;
var Dbdatas = data.GetProperty("other_set");
if (Dbdatas.ValueKind == JsonValueKind.Object)
{
foreach (JsonProperty property in Dbdatas.EnumerateObject())
{
DbData.Add(property.Name.ToString(), property.Value.ToString());
}
}
return true;
}

View File

@ -289,7 +289,7 @@ namespace DualScreenDemo
artist.Name;
artistLabel.Text = artistText;
artistLabel.Tag = artist;
artistLabel.AutoSize = true;
artistLabel.AutoSize = false;
// 計算文字寬度
artistLabel.Font = new Font("微軟正黑體", 22, FontStyle.Bold);
@ -315,8 +315,8 @@ namespace DualScreenDemo
artistLabel.ForeColor = Color.White;
// 標籤座標設定
artistLabel.Location = new Point(singerX, y);
artistLabel.Size = new Size(singerWidth + 20, ItemHeight);
// artistLabel.Size = new Size(singerWidth + 20, ItemHeight);
artistLabel.Size = new Size(700, 66);
Panel separatorPanel = new Panel
{
Location = new Point(singerX, y + ItemHeight),

View File

@ -23,8 +23,8 @@ namespace DualScreenDemo
private List<Image> LoadImagesFromFolder(string folderName)
{
List<Image> images = new();
string folderPath = Utils.Env.GetPath(folderName, "");
// string folderPath = Utils.Env.GetPath(folderName, "");
string folderPath = serverPath+"//"+folderName;
if (folderPath.Equals("")) return images;
string[] imageFiles = Directory.GetFiles(folderPath, "*.jpg");

View File

@ -9,6 +9,8 @@ using Timer = System.Windows.Forms.Timer;
using IniParser.Model;
using IniParser;
using System.Text;
using System.Net.Http;
using System.Threading.Tasks;
namespace DualScreenDemo
@ -128,7 +130,35 @@ namespace DualScreenDemo
private int _currentPage { get; set; } = 0;
private int _totalPages { get; set; }
string serverPath = Utils.Env.GetPath("", "");
// string serverPath = Utils.Env.GetPath("", "");
string serverPath = Application.StartupPath;
// async Task<Bitmap> GetBitmapFromUriAsync(Uri uri)
// {
// using HttpClient client = new HttpClient();
// byte[] imageBytes = await client.GetByteArrayAsync(uri);
// MemoryStream ms = new MemoryStream(imageBytes);
// Bitmap bitmap = new Bitmap(ms);
// Bitmap clonedBitmap = new Bitmap(bitmap);
// ms.Dispose();
// return clonedBitmap;
// }
// private async void LoadBackgroundImage()
// {
// var data = LoadBtnConfigData();
// var hostdata = LoadBtnConfigData();
// string test = hostdata["HeartBeatUrl"] + "/" + data["PrimaryFormBtn"]["AlertNormal1"];
// Console.WriteLine(test);
// Uri remoteUri = new Uri("http://zqd.superstar.dnsnet.cc/themes/superstar/button/1.主類別/主類別上方_新歌快報(未按).png");
// Bitmap bitmap = await GetBitmapFromUriAsync(remoteUri);
// this.BackgroundImage = bitmap;
// this.BackgroundImageLayout = ImageLayout.Stretch; // Optional
// }
public int currentPage
{
@ -2344,7 +2374,18 @@ namespace DualScreenDemo
return parser.ReadData(reader);
}
}
private IniData LoadConfigData()
{
var parser = new FileIniDataParser();
string iniFilePath = Path.Combine(serverPath, "config.ini");
// 使用 UTF-8 讀取 INI 檔案並解析內容
using (var reader = new StreamReader(iniFilePath, Encoding.UTF8))
{
return parser.ReadData(reader);
}
}
//主畫面上排按鍵圖形狀態設置
private void UpdateButtonBackgrounds(Button activeButton, Image activeBackground)
{

View File

@ -6,6 +6,7 @@ namespace DualScreenDemo
{
public static class Program
{
public static heartbeatSender sender = new heartbeatSender();
// 定义全局变量
internal static DBObj.SQLManager songListManager;
//internal static ArtistManager artistManager;
@ -19,10 +20,11 @@ namespace DualScreenDemo
static void Main()
{
Console.WriteLine(verSion);
if (Utils.Env.GetBool("IsCursor", true)) Cursor.Hide();
AppDomain.CurrentDomain.ProcessExit += (s, e) => Cursor.Show();
//Console.WriteLine("正在與中控取得聯繫...");
var sender = new heartbeatSender();
var cherker=new DataCheck.PublicSongChecker(DBObj.SongList.PublicSong());
try
{

View File

@ -56,6 +56,8 @@ namespace DualScreenDemo.Services
public void LoadMedia(string filePath, int audioTrackIndex = 0)
{
_mediaPlayerPrimary.Pause();
_mediaPlayerSecondary.Pause();
_media?.Dispose();
// 建立一個完整有聲音的 Media 給 secondary 播放器
@ -159,19 +161,11 @@ namespace DualScreenDemo.Services
return result;
}
public async Task SetAudioTrackToAsync(int trackIndex)
public void SetAudioTrackToAsync(int trackIndex)
{
var audioTracks = GetAudioTracks();
if (trackIndex < 0 || trackIndex >= audioTracks.Count) return;
if (!_mediaPlayerSecondary.IsPlaying)
{
_mediaPlayerSecondary.Play();
await Task.Delay(500);
}
_mediaPlayerSecondary.SetAudioTrack(audioTracks[trackIndex].Id);
await Task.Delay(300);
}
#endregion

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 60 KiB