diff --git a/CdgPlayer/KaraokeVideoPlayer.cs b/CdgPlayer/KaraokeVideoPlayer.cs index 1838f94..10b3ea1 100644 --- a/CdgPlayer/KaraokeVideoPlayer.cs +++ b/CdgPlayer/KaraokeVideoPlayer.cs @@ -26,11 +26,14 @@ namespace KaraokePlayer // elements of the list change. public event SongEndedEventHandler songEndedHandler; - public KaraokeVideoPlayer(bool isCDG, bool hideOverlay) + public KaraokeVideoPlayer() + { + InitializeComponent(); + } + public void setup(bool isCDG, bool hideOverlay) { this.hideOverlay = hideOverlay; this.isCDG = isCDG; - InitializeComponent(); if (isCDG && !hideOverlay) { this.vlcPlayer.VlcMediaplayerOptions = new string[] { diff --git a/KaraokePlayer/App.config b/KaraokePlayer/App.config index 9350691..b1a2daa 100644 --- a/KaraokePlayer/App.config +++ b/KaraokePlayer/App.config @@ -1,7 +1,24 @@  - + + +
+ + + + - + + + + + + + + + + + \ No newline at end of file diff --git a/KaraokePlayer/MainForm.Designer.cs b/KaraokePlayer/MainForm.Designer.cs index deab5db..1bc6409 100644 --- a/KaraokePlayer/MainForm.Designer.cs +++ b/KaraokePlayer/MainForm.Designer.cs @@ -28,17 +28,19 @@ /// private void InitializeComponent() { + this.karaokeCDGPlayer = new KaraokePlayer.KaraokeVideoPlayer(); + this.karaokeMP4Player = new KaraokePlayer.KaraokeVideoPlayer(); this.btnPlay = new MaterialSkin.Controls.MaterialRaisedButton(); this.btnBrowse = new MaterialSkin.Controls.MaterialRaisedButton(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.btnPlayQueue = new MaterialSkin.Controls.MaterialRaisedButton(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.materialListBox1 = new MaterialSkin.Controls.MaterialListBox(); this.materialSingleLineTextField1 = new MaterialSkin.Controls.MaterialSingleLineTextField(); - this.karaokeCDGPlayer = new KaraokePlayer.KaraokeVideoPlayer(true, true); - this.karaokeMP4Player = new KaraokePlayer.KaraokeVideoPlayer(false, true); this.browseDialog = new System.Windows.Forms.FolderBrowserDialog(); + this.btnStop = new MaterialSkin.Controls.MaterialRaisedButton(); this.tableLayoutPanel1.SuspendLayout(); this.flowLayoutPanel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); @@ -48,11 +50,29 @@ this.tableLayoutPanel2.SuspendLayout(); this.SuspendLayout(); // + // karaokeCDGPlayer + // + this.karaokeCDGPlayer.Dock = System.Windows.Forms.DockStyle.Fill; + this.karaokeCDGPlayer.isCDG = true; + this.karaokeCDGPlayer.Location = new System.Drawing.Point(0, 0); + this.karaokeCDGPlayer.Name = "karaokeCDGPlayer"; + this.karaokeCDGPlayer.Size = new System.Drawing.Size(472, 458); + this.karaokeCDGPlayer.TabIndex = 0; + // + // karaokeMP4Player + // + this.karaokeMP4Player.Dock = System.Windows.Forms.DockStyle.Fill; + this.karaokeMP4Player.isCDG = false; + this.karaokeMP4Player.Location = new System.Drawing.Point(0, 0); + this.karaokeMP4Player.Name = "karaokeMP4Player"; + this.karaokeMP4Player.Size = new System.Drawing.Size(472, 458); + this.karaokeMP4Player.TabIndex = 0; + // // btnPlay // this.btnPlay.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnPlay.Depth = 0; - this.btnPlay.Location = new System.Drawing.Point(629, 3); + this.btnPlay.Location = new System.Drawing.Point(542, 3); this.btnPlay.MouseState = MaterialSkin.MouseState.HOVER; this.btnPlay.Name = "btnPlay"; this.btnPlay.Size = new System.Drawing.Size(81, 37); @@ -65,7 +85,7 @@ // this.btnBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnBrowse.Depth = 0; - this.btnBrowse.Location = new System.Drawing.Point(542, 3); + this.btnBrowse.Location = new System.Drawing.Point(368, 3); this.btnBrowse.MouseState = MaterialSkin.MouseState.HOVER; this.btnBrowse.Name = "btnBrowse"; this.btnBrowse.Size = new System.Drawing.Size(81, 37); @@ -97,7 +117,9 @@ // this.flowLayoutPanel1.AutoSize = true; this.flowLayoutPanel1.BackColor = System.Drawing.Color.Transparent; + this.flowLayoutPanel1.Controls.Add(this.btnStop); this.flowLayoutPanel1.Controls.Add(this.btnPlay); + this.flowLayoutPanel1.Controls.Add(this.btnPlayQueue); this.flowLayoutPanel1.Controls.Add(this.btnBrowse); this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft; @@ -106,6 +128,18 @@ this.flowLayoutPanel1.Size = new System.Drawing.Size(713, 43); this.flowLayoutPanel1.TabIndex = 6; // + // btnPlayQueue + // + this.btnPlayQueue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnPlayQueue.Depth = 0; + this.btnPlayQueue.Location = new System.Drawing.Point(455, 3); + this.btnPlayQueue.MouseState = MaterialSkin.MouseState.HOVER; + this.btnPlayQueue.Name = "btnPlayQueue"; + this.btnPlayQueue.Size = new System.Drawing.Size(81, 37); + this.btnPlayQueue.TabIndex = 3; + this.btnPlayQueue.Text = "Play Queue"; + this.btnPlayQueue.UseVisualStyleBackColor = true; + // // splitContainer1 // this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; @@ -181,19 +215,18 @@ this.materialSingleLineTextField1.UseSystemPasswordChar = false; this.materialSingleLineTextField1.TextChanged += new System.EventHandler(this.materialSingleLineTextField1_TextChanged); // - // karaokeCDGPlayer + // btnStop // - this.karaokeCDGPlayer.Dock = System.Windows.Forms.DockStyle.Fill; - this.karaokeCDGPlayer.Location = new System.Drawing.Point(0, 0); - this.karaokeCDGPlayer.Name = "karaokeCDGPlayer"; - this.karaokeCDGPlayer.Size = new System.Drawing.Size(472, 458); - this.karaokeCDGPlayer.TabIndex = 0; - - this.karaokeMP4Player.Dock = System.Windows.Forms.DockStyle.Fill; - this.karaokeMP4Player.Location = new System.Drawing.Point(0, 0); - this.karaokeMP4Player.Name = "karaokeMP4Player"; - this.karaokeMP4Player.Size = new System.Drawing.Size(472, 458); - this.karaokeMP4Player.TabIndex = 0; + this.btnStop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnStop.Depth = 0; + this.btnStop.Location = new System.Drawing.Point(629, 3); + this.btnStop.MouseState = MaterialSkin.MouseState.HOVER; + this.btnStop.Name = "btnStop"; + this.btnStop.Size = new System.Drawing.Size(81, 37); + this.btnStop.TabIndex = 4; + this.btnStop.Text = "Stop"; + this.btnStop.UseVisualStyleBackColor = true; + this.btnStop.Click += new System.EventHandler(this.btnStop_Click); // // MainForm // @@ -227,5 +260,7 @@ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; private MaterialSkin.Controls.MaterialListBox materialListBox1; private MaterialSkin.Controls.MaterialSingleLineTextField materialSingleLineTextField1; + private MaterialSkin.Controls.MaterialRaisedButton btnPlayQueue; + private MaterialSkin.Controls.MaterialRaisedButton btnStop; } } \ No newline at end of file diff --git a/KaraokePlayer/MainForm.cs b/KaraokePlayer/MainForm.cs index 14acdea..b66fe51 100644 --- a/KaraokePlayer/MainForm.cs +++ b/KaraokePlayer/MainForm.cs @@ -12,10 +12,13 @@ namespace KaraokePlayer { private readonly MaterialSkinManager _materialSkinManager; private List _fileList; + private Song currentSong = null; public MainForm() { InitializeComponent(); + karaokeCDGPlayer.setup(true, true); + karaokeMP4Player.setup(false, true); karaokeCDGPlayer.songEndedHandler += new KaraokePlayer.KaraokeVideoPlayer.SongEndedEventHandler(this.karaokePlayerSongEnded); karaokeMP4Player.songEndedHandler += new KaraokePlayer.KaraokeVideoPlayer.SongEndedEventHandler(this.karaokePlayerSongEnded); // Initialize MaterialSkinManager @@ -72,7 +75,8 @@ namespace KaraokePlayer public void playSelectedFile() { Song file = (Song)materialListBox1.SelectedItem; - if (file.Extension.ToLower() == ".cdg") + currentSong = file; + if (file.Extension.ToLower() == "cdg") { karaokeCDGPlayer.Play(new Uri(Path.ChangeExtension(file.FullPath, ".mp3"))); karaokeCDGPlayer.Visible = true; @@ -91,5 +95,18 @@ namespace KaraokePlayer { //here } + + private void btnStop_Click(object sender, EventArgs e) + { + if (currentSong == null) return; + + if (currentSong.Extension.ToLower() == "cdg") + { + karaokeMP4Player.Stop(); + } + else { + karaokeCDGPlayer.Stop(); + } + } } }