歌庫路徑調整
This commit is contained in:
parent
656f773ec7
commit
1dcd63c6ec
@ -6,6 +6,7 @@ namespace DBObj
|
||||
public string Song { get; set; }
|
||||
public string ArtistA { get; set; }
|
||||
public string ArtistB { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string SongFilePathHost1 { get; set; }
|
||||
public string SongFilePathHost2 { get; set; }
|
||||
public string ArtistASimplified { get; set; }
|
||||
@ -41,12 +42,13 @@ namespace DBObj
|
||||
}
|
||||
|
||||
*/
|
||||
public SongData(string songNumber, string song, string artistA, string artistB, string songFilePathHost1, string songFilePathHost2, string artistASimplified, string artistBSimplified, string songSimplified, int humanVoice)
|
||||
public SongData(string songNumber, string song, string artistA, string artistB, string filename, string songFilePathHost1, string songFilePathHost2, string artistASimplified, string artistBSimplified, string songSimplified, int humanVoice)
|
||||
{
|
||||
SongNumber = songNumber;
|
||||
Song = song;
|
||||
ArtistA = artistA;
|
||||
ArtistB = artistB;
|
||||
FileName = filename;
|
||||
SongFilePathHost1 = songFilePathHost1;
|
||||
SongFilePathHost2 = songFilePathHost2;
|
||||
ArtistASimplified = artistASimplified;
|
||||
|
@ -1,7 +1,3 @@
|
||||
using System.Data.SQLite;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
using System.Diagnostics;
|
||||
using DualScreenDemo;
|
||||
namespace DBObj
|
||||
{
|
||||
@ -17,7 +13,7 @@ namespace DBObj
|
||||
/*
|
||||
public void AddNewUser(string phoneNumber)
|
||||
{
|
||||
string databaseFileName = "KSongDatabase.db";
|
||||
|
||||
string databasePath = Path.Combine(Application.StartupPath, "db", databaseFileName);
|
||||
string connectionString = String.Format("Data Source={0};Version=3;", databasePath);
|
||||
|
||||
|
@ -1513,22 +1513,45 @@ private void DisplayArtists(List<Artist> artists, int page)//歌星點進去後
|
||||
ClearDisplay();
|
||||
DisplaySongs(currentPage);
|
||||
}
|
||||
// 歌庫路徑調整
|
||||
public void AddSongToPlaylist(SongData songData)
|
||||
{
|
||||
try
|
||||
{
|
||||
var filePath1 = songData.SongFilePathHost1;
|
||||
var filePath2 = songData.SongFilePathHost2;
|
||||
|
||||
|
||||
if (!File.Exists(filePath1) && !File.Exists(filePath2))
|
||||
// 之後還要設計成本地的資料夾位置
|
||||
var filename = songData.FileName;
|
||||
bool checkpath = false;
|
||||
string pathToPlay = "";
|
||||
if (File.Exists(filename))
|
||||
{
|
||||
// 點播失敗時,寫LOG至logfile.txt
|
||||
PrimaryForm.WriteLog(String.Format("File not found on both hosts: {0} and {1}", filePath1, filePath2));
|
||||
pathToPlay = filename;
|
||||
checkpath = true;
|
||||
PrimaryForm.WriteLog(String.Format("{0} Using local file: {1}", songData.Song,filename));
|
||||
}
|
||||
else if (File.Exists(filePath1))
|
||||
{
|
||||
pathToPlay = filePath1;
|
||||
checkpath = true;
|
||||
PrimaryForm.WriteLog(String.Format("{0} Using Host1 file: {1}", songData.Song, filePath1));
|
||||
}
|
||||
else if (File.Exists(filePath2))
|
||||
{
|
||||
pathToPlay = filePath2;
|
||||
checkpath = true;
|
||||
PrimaryForm.WriteLog(String.Format("{0} Using Host2 file: {1}", songData.Song, filePath2));
|
||||
}
|
||||
else
|
||||
{
|
||||
var pathToPlay = File.Exists(filePath1) ? filePath1 : filePath2;
|
||||
PrimaryForm.WriteLog(String.Format("File not found on hosts: {0}, {1} and {2}", filename, filePath1, filePath2));
|
||||
}
|
||||
|
||||
if (checkpath)
|
||||
{
|
||||
//做判定 決定pathToPlay值
|
||||
//pathToPlay = File.Exists(filePath1) ? filePath1 : filePath2;
|
||||
|
||||
bool wasEmpty = PrimaryForm.userRequestedSongs.Count == 0;
|
||||
|
||||
PrimaryForm.userRequestedSongs.Add(songData);
|
||||
@ -1554,7 +1577,6 @@ private void DisplayArtists(List<Artist> artists, int page)//歌星點進去後
|
||||
{
|
||||
Console.WriteLine("Error occurred: " + ex.Message);
|
||||
}
|
||||
// OverlayForm.MainForm.displayLabel.Text = String.Format("已點歌曲:{0}", selectedSong);
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace DualScreenDemo{
|
||||
int humanVoice = Convert.ToInt32(reader["vocal"]);
|
||||
|
||||
searchResults.Add(new SongData(
|
||||
songNumber, song, artistA, artistB,
|
||||
songNumber, song, artistA, artistB,fileName,
|
||||
songFilePathHost1, songFilePathHost2,
|
||||
artistASimplified, artistBSimplified,
|
||||
songSimplified, humanVoice
|
||||
|
@ -1596,7 +1596,7 @@ namespace DualScreenDemo
|
||||
//0, // songLength
|
||||
"", // artistA
|
||||
"", // artistB
|
||||
//"", // language
|
||||
"", // filename
|
||||
//"", // category
|
||||
//DateTime.Now, // dateAdded
|
||||
songPath, // songFilePathHost1
|
||||
@ -1624,7 +1624,7 @@ namespace DualScreenDemo
|
||||
//0, // songLength
|
||||
"", // artistA
|
||||
"", // artistB
|
||||
//"", // language
|
||||
"", // filename
|
||||
//"", // category
|
||||
//DateTime.Now, // dateAdded
|
||||
songPath, // songFilePathHost1
|
||||
|
@ -157,7 +157,7 @@ namespace DualScreenDemo
|
||||
if (File.Exists(closePath))
|
||||
{
|
||||
SongData closeSong = new SongData(
|
||||
"0", "結束播放", "", "",
|
||||
"0", "結束播放", "", "", "",
|
||||
closePath, "", "", "", "",
|
||||
1
|
||||
);
|
||||
|
@ -609,7 +609,7 @@ namespace DualScreenDemo
|
||||
if (File.Exists(welcomePath))
|
||||
{
|
||||
publicPlaylist.Add(new SongData(
|
||||
"0", "歡迎光臨", "", "", welcomePath,
|
||||
"0", "歡迎光臨", "", "","", welcomePath,
|
||||
"", "", "", "", 1
|
||||
));
|
||||
}
|
||||
@ -622,7 +622,7 @@ namespace DualScreenDemo
|
||||
{
|
||||
publicPlaylist.Add(new SongData(
|
||||
i.ToString(), $"背景音樂{i:D2}",
|
||||
"", "", bgmPath, "", "", "", "", 1
|
||||
"", "", "",bgmPath, "", "", "", "", 1
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -636,7 +636,7 @@ namespace DualScreenDemo
|
||||
{
|
||||
string fileName = Path.GetFileNameWithoutExtension(songPath);
|
||||
publicPlaylist.Add(new SongData(
|
||||
"0", fileName, "", "",
|
||||
"0", fileName, "", "", "",
|
||||
songPath, "", "", "", "",
|
||||
1
|
||||
));
|
||||
@ -958,7 +958,7 @@ namespace DualScreenDemo
|
||||
if (File.Exists(welcomePath))
|
||||
{
|
||||
publicPlaylist.Add(new SongData(
|
||||
"0", "歡迎光臨", "", "", welcomePath, "", "", "", "", 1
|
||||
"0", "歡迎光臨", "", "", "", welcomePath, "", "", "", "", 1
|
||||
));
|
||||
}
|
||||
|
||||
@ -969,7 +969,7 @@ namespace DualScreenDemo
|
||||
if (File.Exists(bgmPath))
|
||||
{
|
||||
publicPlaylist.Add(new SongData(
|
||||
i.ToString(), $"背景音樂{i:D2}", "", "", bgmPath,
|
||||
i.ToString(), $"背景音樂{i:D2}", "", "", "", bgmPath,
|
||||
"", "", "", "", 1
|
||||
));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user