2509040935

歌曲來源檔案判斷修正
This commit is contained in:
jasonchenwork 2025-09-04 09:36:09 +08:00
parent ba39d2864c
commit 655112dc8c
2 changed files with 11 additions and 7 deletions

View File

@ -75,13 +75,19 @@ namespace DBObj
{ {
try try
{ {
var check = IsFtpUriReachable(new Uri(new Uri(server), basic.getFileName()).ToString());
// string fullPath = Path.Combine(server, basic.getFileName()); // string fullPath = Path.Combine(server, basic.getFileName());
Uri fullUri = new Uri(new Uri(server), basic.getFileName()); Uri fullUri = new Uri(new Uri(server), basic.getFileName());
// if (File.Exists(fullPath)) // if (File.Exists(fullPath))
// { // {
// Console.WriteLine($"找到檔案: {fullPath}"); // Console.WriteLine($"找到檔案: {fullPath}");
return true; // return true;
// } // }
if (check)
{
Console.WriteLine($"找到檔案: {new Uri(new Uri(server), basic.getFileName())}");
return true;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -119,8 +125,8 @@ namespace DBObj
foreach (var server in Utils.Env.GetSongServers()) foreach (var server in Utils.Env.GetSongServers())
{ {
var check = IsFtpUriReachable(new Uri(new Uri(server), filename).ToString());
if (!string.IsNullOrWhiteSpace(server) && check != false) if (!string.IsNullOrWhiteSpace(server)&&FileExistsInServers())
{ {
// Console.WriteLine(new Uri(new Uri(server), filename)); // Console.WriteLine(new Uri(new Uri(server), filename));
return new Uri(new Uri(server), filename); return new Uri(new Uri(server), filename);

View File

@ -351,12 +351,12 @@ namespace DualScreenDemo
string pathToPlay = song.getFile(); string pathToPlay = song.getFile();
Uri url = song.getFileUrl(); Uri url = song.getFileUrl();
//影片畫面播放器載入media設置聲道 //影片畫面播放器載入media設置聲道
if (pathToPlay == null) if(url !=null)
{ {
_mediaService0.LoadMedia(url, 0); _mediaService0.LoadMedia(url, 0);
_mediaService1.LoadMedia(url, song.isPublicSong ? 0 : 1); _mediaService1.LoadMedia(url, song.isPublicSong ? 0 : 1);
} }
else if(pathToPlay != null)
{ {
_mediaService0.LoadMedia(pathToPlay, 0); _mediaService0.LoadMedia(pathToPlay, 0);
_mediaService1.LoadMedia(pathToPlay, song.isPublicSong ? 0 : 1); _mediaService1.LoadMedia(pathToPlay, song.isPublicSong ? 0 : 1);
@ -371,8 +371,6 @@ namespace DualScreenDemo
SetVolume(100 + song.getBasic().getDbChange()); SetVolume(100 + song.getBasic().getDbChange());
Task.Run(() => Thread.Sleep(100)); Task.Run(() => Thread.Sleep(100));
if (isSyncToPrimaryMonitor) SyncToPrimaryMonitor(); if (isSyncToPrimaryMonitor) SyncToPrimaryMonitor();
//ftp抓不到檔案跳下一首歌
if (url == null && !song.isPublicSong) PlayNextSong();
PrimaryForm.Instance.standardKeyButton.PerformClick(); PrimaryForm.Instance.standardKeyButton.PerformClick();
return Task.CompletedTask; return Task.CompletedTask;
} }