diff --git a/KaraokePlayer/App.config b/KaraokePlayer/App.config
index b1a2daa..fd81a85 100644
--- a/KaraokePlayer/App.config
+++ b/KaraokePlayer/App.config
@@ -3,10 +3,9 @@
-
+
-
+
diff --git a/KaraokePlayer/KaraokePlayer.csproj b/KaraokePlayer/KaraokePlayer.csproj
index 837a206..2eac116 100644
--- a/KaraokePlayer/KaraokePlayer.csproj
+++ b/KaraokePlayer/KaraokePlayer.csproj
@@ -34,14 +34,24 @@
4
+
+ ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll
+ True
+
+
+ ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll
+ True
+
False
lib\MaterialSkin.dll
+
+
@@ -51,6 +61,10 @@
+
+ False
+ lib\taglib-sharp.dll
+
@@ -91,6 +105,9 @@
+
+ PreserveNewest
+
diff --git a/KaraokePlayer/MainForm.Designer.cs b/KaraokePlayer/MainForm.Designer.cs
index 1bc6409..fbc71a1 100644
--- a/KaraokePlayer/MainForm.Designer.cs
+++ b/KaraokePlayer/MainForm.Designer.cs
@@ -34,13 +34,13 @@
this.btnBrowse = new MaterialSkin.Controls.MaterialRaisedButton();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
+ this.btnStop = new MaterialSkin.Controls.MaterialRaisedButton();
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.browseDialog = new System.Windows.Forms.FolderBrowserDialog();
- this.btnStop = new MaterialSkin.Controls.MaterialRaisedButton();
this.tableLayoutPanel1.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
@@ -128,6 +128,19 @@
this.flowLayoutPanel1.Size = new System.Drawing.Size(713, 43);
this.flowLayoutPanel1.TabIndex = 6;
//
+ // btnStop
+ //
+ 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);
+ //
// btnPlayQueue
//
this.btnPlayQueue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
@@ -139,6 +152,7 @@
this.btnPlayQueue.TabIndex = 3;
this.btnPlayQueue.Text = "Play Queue";
this.btnPlayQueue.UseVisualStyleBackColor = true;
+ this.btnPlayQueue.Click += new System.EventHandler(this.btnPlayQueue_Click);
//
// splitContainer1
//
@@ -215,19 +229,6 @@
this.materialSingleLineTextField1.UseSystemPasswordChar = false;
this.materialSingleLineTextField1.TextChanged += new System.EventHandler(this.materialSingleLineTextField1_TextChanged);
//
- // btnStop
- //
- 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
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
diff --git a/KaraokePlayer/MainForm.cs b/KaraokePlayer/MainForm.cs
index b66fe51..e005a8b 100644
--- a/KaraokePlayer/MainForm.cs
+++ b/KaraokePlayer/MainForm.cs
@@ -6,14 +6,17 @@ using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Herse.Models;
+using System.IO.Compression;
+
namespace KaraokePlayer
{
public partial class MainForm : MaterialForm
{
+ HerseDb db = new HerseDb();
private readonly MaterialSkinManager _materialSkinManager;
private List _fileList;
private Song currentSong = null;
-
+ private KaraokeVideoPlayer currentPlayer = null;
public MainForm()
{
InitializeComponent();
@@ -37,12 +40,12 @@ namespace KaraokePlayer
{
if (browseDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
- var files = GetFiles(browseDialog.SelectedPath, "*.cdg|*.mp4", searchOption: System.IO.SearchOption.AllDirectories);
- var filtered = files.Where(f => f.Length < 248).ToList();
+ var files = GetFiles(browseDialog.SelectedPath, "*.cdg|*.mp4|*.zip", searchOption: System.IO.SearchOption.AllDirectories);
+ var filtered = files.Where(f => f.Length < 248).ToList();
- _fileList = filtered.Select(file => new Song(file)).ToList();
+ _fileList = filtered.Select(file => CreateSongForPath(file)).ToList();
materialListBox1.DataSource = _fileList;
- materialListBox1.DisplayMember = "FileName";
+ materialListBox1.DisplayMember = "Description";
}
}
@@ -78,12 +81,40 @@ namespace KaraokePlayer
currentSong = file;
if (file.Extension.ToLower() == "cdg")
{
- karaokeCDGPlayer.Play(new Uri(Path.ChangeExtension(file.FullPath, ".mp3")));
+ currentPlayer = karaokeCDGPlayer;
+ karaokeCDGPlayer.Play(new Uri(Path.ChangeExtension(file.FullPath, ".mp3")));
karaokeCDGPlayer.Visible = true;
karaokeMP4Player.Visible = false;
karaokeMP4Player.Stop();
}
+ else if (file.Extension.ToLower() == "zip")
+ {
+ string playPath = null;
+ string extractPath = Path.Combine(Directory.GetCurrentDirectory(), "temp");
+ DeleteDirectory(extractPath);
+ Directory.CreateDirectory(extractPath);
+ using (ZipArchive archive = ZipFile.OpenRead(file.FullPath))
+ {
+ foreach (ZipArchiveEntry entry in archive.Entries)
+ {
+ if (entry.FullName.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase))
+ {
+ playPath = Path.Combine(extractPath, entry.FullName);
+ }
+ entry.ExtractToFile(Path.Combine(extractPath, entry.FullName));
+ }
+ }
+ if (!string.IsNullOrEmpty(playPath))
+ {
+ currentPlayer = karaokeCDGPlayer;
+ karaokeCDGPlayer.Play(new Uri(playPath));
+ karaokeCDGPlayer.Visible = true;
+ karaokeMP4Player.Visible = false;
+ karaokeMP4Player.Stop();
+ }
+ }
else {
+ currentPlayer = karaokeMP4Player;
karaokeMP4Player.Play(new Uri(file.FullPath));
karaokeMP4Player.Visible = true;
karaokeCDGPlayer.Visible = false;
@@ -98,15 +129,41 @@ namespace KaraokePlayer
private void btnStop_Click(object sender, EventArgs e)
{
- if (currentSong == null) return;
+ if (currentPlayer == null) return;
+ currentPlayer.Stop();
+ }
- if (currentSong.Extension.ToLower() == "cdg")
+ private Song CreateSongForPath(string path)
+ {
+ Song song = new Song(path);
+ return song;
+ }
+
+ public void DeleteDirectory(string target_dir)
+ {
+ if (!Directory.Exists(target_dir)) { return; }
+ string[] files = Directory.GetFiles(target_dir);
+ string[] dirs = Directory.GetDirectories(target_dir);
+
+ foreach (string file in files)
{
- karaokeMP4Player.Stop();
+ File.SetAttributes(file, FileAttributes.Normal);
+ File.Delete(file);
}
- else {
- karaokeCDGPlayer.Stop();
+
+ foreach (string dir in dirs)
+ {
+ DeleteDirectory(dir);
}
+
+ Directory.Delete(target_dir, false);
+ }
+
+ private void btnPlayQueue_Click(object sender, EventArgs e)
+ {
+ _fileList = db.Songs.Where(s => s.Id > 0).OrderBy(s=>s.Artist).ThenBy(s=>s.Title).ToList();
+ materialListBox1.DataSource = _fileList;
+ materialListBox1.DisplayMember = "Description";
}
}
}
diff --git a/KaraokePlayer/lib/taglib-sharp.dll b/KaraokePlayer/lib/taglib-sharp.dll
new file mode 100644
index 0000000..4d61148
Binary files /dev/null and b/KaraokePlayer/lib/taglib-sharp.dll differ
diff --git a/KaraokePlayer/packages.config b/KaraokePlayer/packages.config
index 2b0ff15..5e2b87f 100644
--- a/KaraokePlayer/packages.config
+++ b/KaraokePlayer/packages.config
@@ -1,5 +1,6 @@
+
\ No newline at end of file