got end of song working
This commit is contained in:
parent
cdce3825bd
commit
c3e65fcb63
@ -34,6 +34,15 @@ namespace KaraokePlayer.Classes
|
|||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public Song CurrentSong { get; set; }
|
public Song CurrentSong { get; set; }
|
||||||
|
|
||||||
|
public void EndSong()
|
||||||
|
{
|
||||||
|
//_client.DeleteAsync(CurrentSongPath.TrimEnd('/'));
|
||||||
|
var response = _client.Get(string.Format("controllers/{0}/queue", this.Id));
|
||||||
|
List<QueueItem> queue = response.ResultAs<List<QueueItem>>();
|
||||||
|
queue.RemoveAt(0);
|
||||||
|
_client.Set(string.Format("controllers/{0}/queue", this.Id), queue);
|
||||||
|
}
|
||||||
|
|
||||||
public void SetState(PlayerState state)
|
public void SetState(PlayerState state)
|
||||||
{
|
{
|
||||||
_state = state;
|
_state = state;
|
||||||
@ -82,7 +91,7 @@ namespace KaraokePlayer.Classes
|
|||||||
{
|
{
|
||||||
var response = _client.Get(CurrentSongPath);
|
var response = _client.Get(CurrentSongPath);
|
||||||
var item = response.ResultAs<QueueItem>();
|
var item = response.ResultAs<QueueItem>();
|
||||||
if (item == null) return;
|
if (item == null) return;
|
||||||
if (CurrentSong == null || CurrentSong.Path != item.Song.Path)
|
if (CurrentSong == null || CurrentSong.Path != item.Song.Path)
|
||||||
{
|
{
|
||||||
CurrentSong = item.Song;
|
CurrentSong = item.Song;
|
||||||
|
|||||||
@ -21,10 +21,16 @@ namespace KaraokePlayer
|
|||||||
private FirebaseController controller;
|
private FirebaseController controller;
|
||||||
private PlayerWrapper player;
|
private PlayerWrapper player;
|
||||||
|
|
||||||
|
public void SongEnded()
|
||||||
|
{
|
||||||
|
controller.EndSong();
|
||||||
|
}
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
player = new PlayerWrapper(karaokeCDGPlayer, karaokeMP4Player);
|
player = new PlayerWrapper(karaokeCDGPlayer, karaokeMP4Player);
|
||||||
|
player.OnSongEnded += SongEnded;
|
||||||
|
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||||
//this.WindowState = FormWindowState.Maximized;
|
//this.WindowState = FormWindowState.Maximized;
|
||||||
@ -53,7 +59,8 @@ namespace KaraokePlayer
|
|||||||
this.Invoke(new Action(() => { player.stop(); }));
|
this.Invoke(new Action(() => { player.stop(); }));
|
||||||
player.Song = args.Song;
|
player.Song = args.Song;
|
||||||
this.Invoke(new Action(() => { previewSong(); }));
|
this.Invoke(new Action(() => { previewSong(); }));
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void previewSong()
|
private async void previewSong()
|
||||||
|
|||||||
@ -18,6 +18,9 @@ namespace KaraokePlayer
|
|||||||
private KaraokeVideoPlayer cdgPlayer;
|
private KaraokeVideoPlayer cdgPlayer;
|
||||||
public Song Song { get; set; }
|
public Song Song { get; set; }
|
||||||
|
|
||||||
|
public delegate void SongEndedEventHandler();
|
||||||
|
public SongEndedEventHandler OnSongEnded { get; set; }
|
||||||
|
|
||||||
public PlayerWrapper(KaraokeVideoPlayer cdgPlayer, KaraokeVideoPlayer mp4Player)
|
public PlayerWrapper(KaraokeVideoPlayer cdgPlayer, KaraokeVideoPlayer mp4Player)
|
||||||
{
|
{
|
||||||
cdgPlayer.setup(true, true);
|
cdgPlayer.setup(true, true);
|
||||||
@ -32,15 +35,15 @@ namespace KaraokePlayer
|
|||||||
|
|
||||||
private void karaokePlayerSongEnded(object sender, EventArgs e)
|
private void karaokePlayerSongEnded(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
//TODO: figure out how to play the next song. probably just delete the current one
|
if (OnSongEnded != null) OnSongEnded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void stop()
|
public void stop()
|
||||||
{
|
{
|
||||||
if (currentPlayer == null) return;
|
if (currentPlayer == null) return;
|
||||||
currentPlayer.Stop();
|
currentPlayer.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pause()
|
public void pause()
|
||||||
{
|
{
|
||||||
if (currentPlayer == null) return;
|
if (currentPlayer == null) return;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user