2025-07-14 18:08:12 +08:00
|
|
|
using DualScreenDemo;
|
|
|
|
using System;
|
|
|
|
using System.IO;
|
2025-08-08 16:31:26 +08:00
|
|
|
using System.Numerics;
|
2025-07-14 18:08:12 +08:00
|
|
|
using System.Windows.Navigation;
|
|
|
|
namespace DBObj
|
|
|
|
{
|
|
|
|
public class SongList
|
|
|
|
{
|
2025-07-17 18:08:22 +08:00
|
|
|
private static bool isWelcome = true;
|
|
|
|
public static SongData welcome;
|
2025-08-08 16:32:54 +08:00
|
|
|
public static SongData close;
|
|
|
|
private static SongData publicPlaying = null;
|
2025-07-14 18:08:12 +08:00
|
|
|
private static List<SongData> publicSong = new();
|
2025-08-08 16:32:54 +08:00
|
|
|
private static SongData playing = null;
|
2025-07-14 18:08:12 +08:00
|
|
|
private static List<SongData> not_played = new List<SongData>();
|
|
|
|
private static List<SongData> played = new List<SongData>();
|
|
|
|
public static List<SongData> PublicSong() => publicSong;
|
|
|
|
|
|
|
|
public static SongData Current()
|
|
|
|
{
|
|
|
|
Console.WriteLine(not_played.Count + " Current " + playing);
|
2025-08-08 16:32:54 +08:00
|
|
|
return (playing == null) ? publicPlaying : playing;
|
2025-07-14 18:08:12 +08:00
|
|
|
}
|
|
|
|
public static SongData Next()
|
|
|
|
{
|
|
|
|
if (playing != null)
|
|
|
|
{
|
|
|
|
playing.SetState(PlayState.Played);
|
|
|
|
played.Add(playing);
|
|
|
|
playing = null;
|
|
|
|
}
|
|
|
|
if (not_played.Count <= 0)
|
|
|
|
return NextPublicSong();
|
|
|
|
else
|
|
|
|
return NextUserSong();
|
|
|
|
}
|
|
|
|
private static SongData NextUserSong()
|
|
|
|
{
|
|
|
|
playing = not_played[0];
|
|
|
|
not_played.RemoveAt(0);
|
2025-08-01 16:37:33 +08:00
|
|
|
|
|
|
|
if (!playing.FileExistsInServers())
|
|
|
|
{
|
|
|
|
playing.SetState(PlayState.NoFile);
|
|
|
|
played.Add(playing);
|
|
|
|
playing = null;
|
|
|
|
if (not_played.Count <= 0)
|
|
|
|
return NextPublicSong();
|
|
|
|
else
|
|
|
|
return NextUserSong();
|
|
|
|
}
|
|
|
|
|
2025-07-14 18:08:12 +08:00
|
|
|
playing.SetState(PlayState.Playing);
|
2025-08-01 16:37:33 +08:00
|
|
|
|
2025-07-14 18:08:12 +08:00
|
|
|
UpdateNextSongLabel();
|
|
|
|
return playing;
|
|
|
|
}
|
|
|
|
private static SongData NextPublicSong()
|
|
|
|
{
|
2025-08-08 16:32:54 +08:00
|
|
|
if (Program.room.IsClose())
|
|
|
|
{
|
2025-07-17 18:08:22 +08:00
|
|
|
publicPlaying = close;
|
2025-08-08 16:32:54 +08:00
|
|
|
}
|
|
|
|
else if (Program.room.IsOpen() && isWelcome)
|
|
|
|
{
|
2025-07-17 18:08:22 +08:00
|
|
|
isWelcome = false;
|
|
|
|
publicPlaying = welcome;
|
2025-08-08 16:32:54 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2025-07-17 18:08:22 +08:00
|
|
|
publicPlaying = publicSong[0];
|
|
|
|
publicSong.RemoveAt(0);
|
|
|
|
publicSong.Add(publicPlaying);
|
|
|
|
}
|
2025-08-08 16:32:54 +08:00
|
|
|
|
2025-07-14 18:08:12 +08:00
|
|
|
return publicPlaying;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static List<SongData> GetHistory()
|
|
|
|
{
|
|
|
|
List<SongData> History = [.. played];
|
|
|
|
if (playing != null) History.Add(playing);
|
|
|
|
History.AddRange(not_played);
|
|
|
|
return History;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Add(SongData song)
|
|
|
|
{
|
2025-08-01 16:37:33 +08:00
|
|
|
if (song.FileExistsInServers())
|
|
|
|
{
|
|
|
|
not_played.Add(new SongData(song, PlayState.NotPlayed));
|
|
|
|
// PrimaryForm.Instance.AddSongCount(songData.Number);
|
|
|
|
chkCut();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
played.Add(new SongData(song, PlayState.NoFile));
|
|
|
|
}
|
2025-08-08 16:32:54 +08:00
|
|
|
|
2025-07-14 18:08:12 +08:00
|
|
|
}
|
2025-08-08 16:31:26 +08:00
|
|
|
|
2025-08-08 16:32:54 +08:00
|
|
|
public static void Cancel(SongData song)
|
2025-08-08 16:31:26 +08:00
|
|
|
{
|
2025-09-05 12:12:29 +08:00
|
|
|
if (song.GetState() == PlayState.NotPlayed||song.GetState() ==PlayState.InsertPlayback)
|
2025-08-26 16:31:53 +08:00
|
|
|
{
|
|
|
|
not_played.Remove(song);
|
|
|
|
song.SetState(PlayState.Skipped);
|
|
|
|
played.Add(song);
|
|
|
|
}
|
|
|
|
|
2025-08-08 16:31:26 +08:00
|
|
|
}
|
|
|
|
|
2025-07-14 18:08:12 +08:00
|
|
|
public static void Insert(SongData song)
|
|
|
|
{
|
2025-08-08 16:32:54 +08:00
|
|
|
if (song.FileExistsInServers())
|
|
|
|
{
|
|
|
|
not_played.Insert(0, new SongData(song, PlayState.InsertPlayback));
|
2025-08-01 16:37:33 +08:00
|
|
|
chkCut();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
played.Add(new SongData(song, PlayState.NoFile));
|
|
|
|
}
|
2025-08-08 16:32:54 +08:00
|
|
|
|
2025-07-14 18:08:12 +08:00
|
|
|
}
|
|
|
|
private static void chkCut()
|
|
|
|
{
|
|
|
|
if (playing == null)
|
|
|
|
{
|
|
|
|
if (PrimaryForm.Instance.InvokeRequired)
|
|
|
|
PrimaryForm.Instance.Invoke(new System.Action(() => PrimaryForm.Instance.videoPlayerForm.PlayNextSong()));
|
|
|
|
else
|
|
|
|
PrimaryForm.Instance.videoPlayerForm.PlayNextSong();
|
2025-08-08 16:32:54 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2025-07-14 18:08:12 +08:00
|
|
|
UpdateNextSongLabel();
|
|
|
|
}
|
|
|
|
}
|
2025-08-08 16:32:54 +08:00
|
|
|
|
2025-07-14 18:08:12 +08:00
|
|
|
public static void UpdateNextSongLabel()
|
|
|
|
{
|
2025-08-08 16:32:54 +08:00
|
|
|
if (Program.room.IsClose())
|
|
|
|
{
|
2025-07-30 09:30:31 +08:00
|
|
|
VideoPlayerForm.overlayForm.UpdateTopLeftLabel(" ");
|
2025-08-08 16:32:54 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2025-07-30 09:30:31 +08:00
|
|
|
VideoPlayerForm.overlayForm.UpdateTopLeftLabel(
|
|
|
|
(not_played.Count > 0) ? not_played[0].next_song_text() : "目前沒有下一首,請踴躍點歌!!!"
|
|
|
|
);
|
|
|
|
}
|
2025-08-08 16:32:54 +08:00
|
|
|
|
2025-07-14 18:08:12 +08:00
|
|
|
}
|
2025-08-04 11:08:40 +08:00
|
|
|
public static void roomClose()
|
|
|
|
{
|
|
|
|
SongData song;
|
|
|
|
while (not_played.Count > 0)
|
|
|
|
{
|
|
|
|
song = not_played[0];
|
|
|
|
not_played.RemoveAt(0);
|
|
|
|
song.SetState(PlayState.Skipped);
|
|
|
|
played.Add(song);
|
|
|
|
}
|
|
|
|
}
|
2025-07-14 18:08:12 +08:00
|
|
|
public static void clearSong()
|
|
|
|
{
|
2025-07-17 18:08:22 +08:00
|
|
|
isWelcome = true;
|
2025-07-14 18:08:12 +08:00
|
|
|
not_played.Clear();
|
|
|
|
played.Clear();
|
|
|
|
}
|
2025-08-08 16:32:54 +08:00
|
|
|
|
2025-07-14 18:08:12 +08:00
|
|
|
}
|
|
|
|
}
|