98 lines
3.0 KiB
C#
98 lines
3.0 KiB
C#
using DualScreenDemo;
|
|
using System;
|
|
using System.IO;
|
|
using System.Windows.Navigation;
|
|
namespace DBObj
|
|
{
|
|
public class SongList
|
|
{
|
|
public static SongData welcome ;
|
|
public static SongData close ;
|
|
private static SongData publicPlaying=null;
|
|
private static List<SongData> publicSong = new();
|
|
private static SongData playing=null;
|
|
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);
|
|
return (playing ==null) ? publicPlaying : playing;
|
|
}
|
|
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);
|
|
playing.SetState(PlayState.Playing);
|
|
UpdateNextSongLabel();
|
|
return playing;
|
|
}
|
|
private static SongData NextPublicSong()
|
|
{
|
|
publicPlaying = publicSong[0];
|
|
publicSong.RemoveAt(0);
|
|
publicSong.Add(publicPlaying);
|
|
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)
|
|
{
|
|
not_played.Add(song);
|
|
// PrimaryForm.Instance.AddSongCount(songData.Number);
|
|
chkCut();
|
|
}
|
|
public static void Insert(SongData song)
|
|
{
|
|
song.SetState(PlayState.InsertPlayback);
|
|
not_played.Insert(0, song);
|
|
chkCut();
|
|
}
|
|
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();
|
|
} else {
|
|
UpdateNextSongLabel();
|
|
}
|
|
}
|
|
|
|
public static void UpdateNextSongLabel()
|
|
{
|
|
VideoPlayerForm.overlayForm.UpdateTopLeftLabel(
|
|
(not_played.Count > 0) ? not_played[0].getName() : "目前沒有下一首,請踴躍點歌!!!"
|
|
);
|
|
}
|
|
public static void clearSong()
|
|
{
|
|
not_played.Clear();
|
|
played.Clear();
|
|
}
|
|
}
|
|
}
|