2508141752
1.DBConnection參數獲取方式修改 2.歌手VOD選取範圍修正 3.撥放器微調
8
Env.cs
@ -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();
|
||||
@ -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 等
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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),
|
||||
|
@ -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");
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 79 KiB |
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 60 KiB |