refactored to song

Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
Matt Bruce 2016-03-21 22:06:56 -05:00
parent 1d37853346
commit be8f8a328e
4 changed files with 93 additions and 21 deletions

View File

@ -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[] {

View File

@ -1,7 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add providerName="System.Data.SqlClient"
connectionString="Data Source=tcp:herse.database.windows.net,1433;Initial Catalog=herse;Persist Security Info=True;User ID=herse;password=94diablo!" name="HerseDb"/>
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>

View File

@ -28,17 +28,19 @@
/// </summary>
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;
}
}

View File

@ -12,10 +12,13 @@ namespace KaraokePlayer
{
private readonly MaterialSkinManager _materialSkinManager;
private List<Song> _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();
}
}
}
}