using System; using MaterialSkin; using MaterialSkin.Controls; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.IO.Compression; using System.Windows.Forms; using KaraokePlayer.Classes; using System.Threading.Tasks; using System.Configuration; using Herse.Models; namespace KaraokePlayer { public partial class MainForm : Form { private SongInfoForm songInfoForm = new SongInfoForm(); private delegate void Action(); private FirebaseController controller; private PlayerWrapper player; public MainForm() { InitializeComponent(); player = new PlayerWrapper(karaokeCDGPlayer, karaokeMP4Player); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; //this.WindowState = FormWindowState.Maximized; this.ShowInTaskbar = true; controller = new FirebaseController( clientId: ConfigurationManager.AppSettings["KaraokePlayer.ControllerId"], stateChanged: (args) => { switch (args.State) { case PlayerState.playing: this.Invoke(new Action(() => { player.play(); })); break; case PlayerState.paused: this.Invoke(new Action(() => { player.pause(); })); break; case PlayerState.stopped: this.Invoke(new Action(() => { player.stop(); })); break; } }, songChanged: (args) => { this.Invoke(new Action(() => { player.stop(); })); player.Song = args.Song; this.Invoke(new Action(() => { previewSong(); })); }); } private async void previewSong() { songInfoForm.Update(player.Song); songInfoForm.Show(); await Task.Delay(TimeSpan.FromSeconds(5)); player.play(); controller.SetState(PlayerState.playing); songInfoForm.Hide(); } } }