diff --git a/CdgPlayer/KaraokeVideoPlayer.cs b/CdgPlayer/KaraokeVideoPlayer.cs
index 10b3ea1..7f72f8f 100644
--- a/CdgPlayer/KaraokeVideoPlayer.cs
+++ b/CdgPlayer/KaraokeVideoPlayer.cs
@@ -15,7 +15,7 @@ namespace KaraokePlayer
{
public partial class KaraokeVideoPlayer : UserControl
{
-
+ public bool isPaused = false;
private bool hideOverlay = true;
private GraphicsFile _cdgFile;
private KaraokeVideoOverlay _overlayForm;
@@ -76,11 +76,24 @@ namespace KaraokePlayer
vlcPlayer.Play();
}
+ public void Resume()
+ {
+ isPaused = false;
+ vlcPlayer.Play();
+ }
+
public void Stop()
{
+ isPaused = false;
vlcPlayer.Stop();
}
+ public void Pause()
+ {
+ isPaused = true;
+ vlcPlayer.Pause();
+ }
+
private void vlcPlayer_Playing(object sender, VlcMediaPlayerPlayingEventArgs e)
{
_startTime = DateTime.Now;
diff --git a/ConsoleApplication1/App.config b/ConsoleApplication1/App.config
new file mode 100644
index 0000000..88fa402
--- /dev/null
+++ b/ConsoleApplication1/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ConsoleApplication1/ConsoleApplication1.csproj b/ConsoleApplication1/ConsoleApplication1.csproj
new file mode 100644
index 0000000..b0bb495
--- /dev/null
+++ b/ConsoleApplication1/ConsoleApplication1.csproj
@@ -0,0 +1,60 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {19F06EDF-92BA-40A9-BBFC-1DA75C894059}
+ Exe
+ Properties
+ ConsoleApplication1
+ ConsoleApplication1
+ v4.5.2
+ 512
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ConsoleApplication1/Program.cs b/ConsoleApplication1/Program.cs
new file mode 100644
index 0000000..99abfb2
--- /dev/null
+++ b/ConsoleApplication1/Program.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ConsoleApplication1
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ }
+ }
+}
diff --git a/ConsoleApplication1/Properties/AssemblyInfo.cs b/ConsoleApplication1/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..3efa712
--- /dev/null
+++ b/ConsoleApplication1/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("ConsoleApplication1")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("ConsoleApplication1")]
+[assembly: AssemblyCopyright("Copyright © 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("19f06edf-92ba-40a9-bbfc-1da75c894059")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/KaraokePlayer.sln b/KaraokePlayer.sln
index e8be43f..8f52ca3 100644
--- a/KaraokePlayer.sln
+++ b/KaraokePlayer.sln
@@ -13,8 +13,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KaraokePlayer", "KaraokePla
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CdgPlayer", "CdgPlayer\CdgPlayer.csproj", "{A5324295-6BD2-4415-92CD-6EA77D708E00}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Herse.Models", "..\herse.models\Herse.Models.csproj", "{BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -33,10 +31,6 @@ Global
{A5324295-6BD2-4415-92CD-6EA77D708E00}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5324295-6BD2-4415-92CD-6EA77D708E00}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5324295-6BD2-4415-92CD-6EA77D708E00}.Release|Any CPU.Build.0 = Release|Any CPU
- {BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {BDE9BC7B-DB3D-4A28-9902-B5D8D1965E5C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/KaraokePlayer/App.config b/KaraokePlayer/App.config
index fd81a85..dd5da42 100644
--- a/KaraokePlayer/App.config
+++ b/KaraokePlayer/App.config
@@ -20,4 +20,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/KaraokePlayer/Classes/Enums.cs b/KaraokePlayer/Classes/Enums.cs
new file mode 100644
index 0000000..d5a9bc5
--- /dev/null
+++ b/KaraokePlayer/Classes/Enums.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace KaraokePlayer.Enums
+{
+ public enum PlayerState
+ {
+ Play,
+ Stop,
+ Pause,
+ Next
+ }
+
+ public enum FileType
+ {
+ CDG, MP4, ZIP
+ }
+}
diff --git a/KaraokePlayer/Classes/FirebaseController.cs b/KaraokePlayer/Classes/FirebaseController.cs
new file mode 100644
index 0000000..4f8f250
--- /dev/null
+++ b/KaraokePlayer/Classes/FirebaseController.cs
@@ -0,0 +1,196 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using KaraokePlayer.Interfaces;
+using KaraokePlayer.Enums;
+using FireSharp.Interfaces;
+using FireSharp.Config;
+using FireSharp;
+
+namespace KaraokePlayer.Classes
+{
+ public class FirebaseSong : ISong
+ {
+ public string FirebaseId { get; set; }
+ public int Id { get; set; }
+ public int Order { get; set; }
+ public string Title { get; set; }
+ public string Artist { get; set; }
+ public FileType FileType { get; set; }
+ public string Path { get; set; }
+ }
+
+ public class FirebaseController : IController
+ {
+ private IFirebaseConfig config = new FirebaseConfig
+ {
+ AuthSecret = "wj0ERDFZqNSysTtIXcCgCr8Itahr6pJOBeqCjvDF",
+ BasePath = "https://karaokecontroller.firebaseio.com/"
+ };
+ private IFirebaseClient client;
+ private ControllerStateChangedEventHandler StateChanged;
+ private ControllerSongChangedEventHandler SongChanged;
+
+ public FirebaseController(ControllerStateChangedEventHandler stateChanged, ControllerSongChangedEventHandler songChanged)
+ {
+ StateChanged = stateChanged;
+ SongChanged = songChanged;
+ PlayQueue = new List();
+ client = new FirebaseClient(config);
+ client.DeleteAsync("controller/state");
+ client.PushAsync("controller/state", "stop");
+ client.DeleteAsync("controller/playQueue");
+ client.DeleteAsync("controller/currentSong");
+ ListenToStream();
+ }
+
+ public int Id { get; set; }
+ public List PlayQueue { get; set; }
+ public void GetNextSong()
+ {
+ ISong song = PlayQueue.FirstOrDefault();
+ Stop();
+ client.DeleteAsync("controller/currentSong");
+ client.PushAsync("controller/currentSong", song);
+ }
+ public void RemoveSong(ISong song)
+ {
+ ISong found = PlayQueue.FirstOrDefault(s => s.Id == song.Id);
+ if (found != null)
+ {
+ PlayQueue.Remove(found);
+ client.DeleteAsync("controller/playQueue/" + ((FirebaseSong)song).FirebaseId);
+ }
+ }
+ public void Next()
+ {
+ client.DeleteAsync("controller/state");
+ client.PushAsync("controller/state", "next");
+ }
+
+ public void Play()
+ {
+ client.DeleteAsync("controller/state");
+ client.PushAsync("controller/state", "play");
+ }
+
+ public void Stop()
+ {
+ client.DeleteAsync("controller/state");
+ client.PushAsync("controller/state", "stop");
+ }
+
+ public void Pause()
+ {
+ client.DeleteAsync("controller/state");
+ client.PushAsync("controller/state", "pause");
+ }
+
+ private async void ListenToStream()
+ {
+ await client.OnAsync("controller/currentSong",
+ added: (s, args, obj) =>
+ {
+ if (args.Path.Contains("Id"))
+ {
+ CurrentSongChanged();
+ }
+ },
+ changed: (s, args, obj) =>
+ {
+ if (args.Path.Contains("Id"))
+ {
+ CurrentSongChanged();
+ }
+ },
+ removed: null
+ );
+
+ await client.OnAsync("controller/playQueue",
+ added: (s, args, obj) =>
+ {
+ if (args.Path.Contains("Id"))
+ {
+ ReloadPlayQueue();
+ }
+ },
+ changed: (s, args, obj) =>
+ {
+ if (args.Path.Contains("Id"))
+ {
+ ReloadPlayQueue();
+ }
+ },
+ removed: null
+ );
+
+ await client.OnAsync("controller/state",
+ added: (s, args, obj) =>
+ {
+ RemoteStateChanged(args.Data);
+ },
+ changed: (s, args, obj) =>
+ {
+ RemoteStateChanged(args.Data);
+ },
+ removed: null
+ );
+ }
+
+ private void ReloadPlayQueue()
+ {
+ bool autoPlay = PlayQueue.Count() == 0;
+ var response = client.Get("controller/playQueue");
+ var dict = response.ResultAs>();
+
+ PlayQueue.Clear();
+ if (dict.Count() > 0)
+ {
+ foreach (KeyValuePair entry in dict)
+ {
+ entry.Value.FirebaseId = entry.Key;
+ }
+
+ var array = dict.Values.OrderBy(s => s.Order).ToArray();
+ PlayQueue.AddRange(array);
+ if (autoPlay)
+ {
+ GetNextSong();
+ }
+ }
+ }
+
+ private void CurrentSongChanged()
+ {
+ var response = client.Get("controller/currentSong");
+ var dict = response.ResultAs>();
+
+ var song = dict.Values.FirstOrDefault();
+ if (song != null)
+ {
+ SongChanged(new ControllerSongChangedEventArgs(false, song));
+ }
+ }
+
+ private void RemoteStateChanged(string state)
+ {
+ PlayerState s = PlayerState.Play;
+ if(state.ToLower() == "pause")
+ {
+ s = PlayerState.Pause;
+ }
+ else if (state.ToLower() == "stop")
+ {
+ s = PlayerState.Stop;
+ }
+ else if (state == "next")
+ {
+ s = PlayerState.Next;
+ }
+ StateChanged(new ControllerStateChangedEventArgs(s));
+ }
+
+ }
+}
diff --git a/KaraokePlayer/Classes/Interfaces.cs b/KaraokePlayer/Classes/Interfaces.cs
new file mode 100644
index 0000000..d628372
--- /dev/null
+++ b/KaraokePlayer/Classes/Interfaces.cs
@@ -0,0 +1,31 @@
+using KaraokePlayer.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace KaraokePlayer.Interfaces
+{
+ public interface ISong
+ {
+ int Id { get; set; }
+ int Order { get; set; }
+ string Title { get; set; }
+ string Artist { get; set; }
+ FileType FileType { get; set; }
+ string Path { get; set; }
+ }
+
+ public interface IController
+ {
+ int Id { get; set; }
+ List PlayQueue { get; set; }
+ void GetNextSong();
+ void RemoveSong(ISong song);
+ void Play();
+ void Pause();
+ void Stop();
+ void Next();
+ }
+}
diff --git a/KaraokePlayer/Classes/PlayerDelegates.cs b/KaraokePlayer/Classes/PlayerDelegates.cs
new file mode 100644
index 0000000..df05338
--- /dev/null
+++ b/KaraokePlayer/Classes/PlayerDelegates.cs
@@ -0,0 +1,38 @@
+using KaraokePlayer.Enums;
+using KaraokePlayer.Interfaces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace KaraokePlayer.Classes
+{
+ public class ControllerStateChangedEventArgs: EventArgs
+ {
+ public ControllerStateChangedEventArgs(PlayerState state )
+ {
+ State = state;
+ }
+ public PlayerState State { get; }
+ }
+ public class ControllerSongChangedEventArgs
+ {
+ public ControllerSongChangedEventArgs(ISong song)
+ {
+ ShouldPlay = true;
+ Song = song;
+ }
+ public ControllerSongChangedEventArgs(bool shouldPlay, ISong song)
+ {
+ ShouldPlay = shouldPlay;
+ Song = song;
+ }
+ public ISong Song { get; }
+ public bool ShouldPlay { get; }
+ }
+
+ public delegate void ControllerStateChangedEventHandler(ControllerStateChangedEventArgs args);
+ public delegate void ControllerSongChangedEventHandler(ControllerSongChangedEventArgs args);
+
+}
diff --git a/KaraokePlayer/KaraokePlayer.csproj b/KaraokePlayer/KaraokePlayer.csproj
index 2eac116..1549387 100644
--- a/KaraokePlayer/KaraokePlayer.csproj
+++ b/KaraokePlayer/KaraokePlayer.csproj
@@ -12,6 +12,21 @@
v4.6
512
true
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 1.0.0.%2a
+ false
+ false
+ true
AnyCPU
@@ -42,16 +57,46 @@
..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll
True
+
+ ..\packages\FireSharp.2.0.4\lib\portable-net45+sl5+wp8+win8\FireSharp.dll
+ True
+
False
lib\MaterialSkin.dll
+
+ ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll
+ True
+
+
+ ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll
+ True
+
+
+ ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll
+ True
+
+
+ ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll
+ True
+
+
+
+ ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll
+ True
+
+
+ ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll
+ True
+
+
@@ -61,12 +106,12 @@
-
- False
- lib\taglib-sharp.dll
-
+
+
+
+
Form
@@ -75,6 +120,12 @@
+
+ Form
+
+
+ SongInfoForm.cs
+
MainForm.cs
@@ -88,6 +139,9 @@
Resources.resx
True
+
+ SongInfoForm.cs
+
@@ -412,15 +466,23 @@
-
- {bde9bc7b-db3d-4a28-9902-b5d8d1965e5c}
- Herse.Models
-
{a5324295-6bd2-4415-92cd-6ea77d708e00}
CdgPlayer
+
+
+ False
+ Microsoft .NET Framework 4.6 %28x86 and x64%29
+ true
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
XCOPY "$(ProjectDir)lib" "$(TargetDir)lib\" /S /y /c
diff --git a/KaraokePlayer/MainForm.Designer.cs b/KaraokePlayer/MainForm.Designer.cs
index fbc71a1..3a80e99 100644
--- a/KaraokePlayer/MainForm.Designer.cs
+++ b/KaraokePlayer/MainForm.Designer.cs
@@ -30,24 +30,6 @@
{
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.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.tableLayoutPanel1.SuspendLayout();
- this.flowLayoutPanel1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
- this.splitContainer1.Panel1.SuspendLayout();
- this.splitContainer1.Panel2.SuspendLayout();
- this.splitContainer1.SuspendLayout();
- this.tableLayoutPanel2.SuspendLayout();
this.SuspendLayout();
//
// karaokeCDGPlayer
@@ -56,7 +38,7 @@
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.Size = new System.Drawing.Size(1024, 768);
this.karaokeCDGPlayer.TabIndex = 0;
//
// karaokeMP4Player
@@ -65,203 +47,24 @@
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.Size = new System.Drawing.Size(1024, 768);
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(542, 3);
- this.btnPlay.MouseState = MaterialSkin.MouseState.HOVER;
- this.btnPlay.Name = "btnPlay";
- this.btnPlay.Size = new System.Drawing.Size(81, 37);
- this.btnPlay.TabIndex = 1;
- this.btnPlay.Text = "Play";
- this.btnPlay.UseVisualStyleBackColor = true;
- this.btnPlay.Click += new System.EventHandler(this.materialRaisedButton1_Click);
- //
- // btnBrowse
- //
- 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(368, 3);
- this.btnBrowse.MouseState = MaterialSkin.MouseState.HOVER;
- this.btnBrowse.Name = "btnBrowse";
- this.btnBrowse.Size = new System.Drawing.Size(81, 37);
- this.btnBrowse.TabIndex = 2;
- this.btnBrowse.Text = "Browse";
- this.btnBrowse.UseVisualStyleBackColor = true;
- this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click);
- //
- // tableLayoutPanel1
- //
- this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.tableLayoutPanel1.BackColor = System.Drawing.Color.Transparent;
- this.tableLayoutPanel1.ColumnCount = 1;
- this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
- this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
- this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 1);
- this.tableLayoutPanel1.Controls.Add(this.splitContainer1, 0, 0);
- this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 71);
- this.tableLayoutPanel1.Name = "tableLayoutPanel1";
- this.tableLayoutPanel1.RowCount = 2;
- this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
- this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
- this.tableLayoutPanel1.Size = new System.Drawing.Size(719, 513);
- this.tableLayoutPanel1.TabIndex = 5;
- //
- // flowLayoutPanel1
- //
- 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;
- this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 467);
- this.flowLayoutPanel1.Name = "flowLayoutPanel1";
- 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)));
- 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;
- this.btnPlayQueue.Click += new System.EventHandler(this.btnPlayQueue_Click);
- //
- // splitContainer1
- //
- this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.splitContainer1.Location = new System.Drawing.Point(3, 3);
- this.splitContainer1.Name = "splitContainer1";
- //
- // splitContainer1.Panel1
- //
- this.splitContainer1.Panel1.Controls.Add(this.tableLayoutPanel2);
- //
- // splitContainer1.Panel2
- //
- this.splitContainer1.Panel2.Controls.Add(this.karaokeCDGPlayer);
- this.splitContainer1.Panel2.Controls.Add(this.karaokeMP4Player);
- this.splitContainer1.Size = new System.Drawing.Size(713, 458);
- this.splitContainer1.SplitterDistance = 237;
- this.splitContainer1.TabIndex = 6;
- //
- // tableLayoutPanel2
- //
- this.tableLayoutPanel2.BackColor = System.Drawing.SystemColors.Control;
- this.tableLayoutPanel2.ColumnCount = 1;
- this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
- this.tableLayoutPanel2.Controls.Add(this.materialListBox1, 0, 1);
- this.tableLayoutPanel2.Controls.Add(this.materialSingleLineTextField1, 0, 0);
- this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
- this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0);
- this.tableLayoutPanel2.Name = "tableLayoutPanel2";
- this.tableLayoutPanel2.RowCount = 2;
- this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
- this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
- this.tableLayoutPanel2.Size = new System.Drawing.Size(237, 458);
- this.tableLayoutPanel2.TabIndex = 7;
- //
- // materialListBox1
- //
- this.materialListBox1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
- this.materialListBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.materialListBox1.Depth = 0;
- this.materialListBox1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.materialListBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
- this.materialListBox1.Font = new System.Drawing.Font("Roboto", 24F);
- this.materialListBox1.FormattingEnabled = true;
- this.materialListBox1.Items.AddRange(new object[] {
- "1",
- "2",
- "3",
- "4"});
- this.materialListBox1.Location = new System.Drawing.Point(3, 32);
- this.materialListBox1.MouseLocation = new System.Drawing.Point(-1, -1);
- this.materialListBox1.MouseState = MaterialSkin.MouseState.HOVER;
- this.materialListBox1.Name = "materialListBox1";
- this.materialListBox1.Size = new System.Drawing.Size(231, 423);
- this.materialListBox1.TabIndex = 5;
- this.materialListBox1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.materialListBox1_MouseDoubleClick);
- //
- // materialSingleLineTextField1
- //
- this.materialSingleLineTextField1.Depth = 0;
- this.materialSingleLineTextField1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.materialSingleLineTextField1.Hint = "";
- this.materialSingleLineTextField1.Location = new System.Drawing.Point(3, 3);
- this.materialSingleLineTextField1.MaxLength = 32767;
- this.materialSingleLineTextField1.MouseState = MaterialSkin.MouseState.HOVER;
- this.materialSingleLineTextField1.Name = "materialSingleLineTextField1";
- this.materialSingleLineTextField1.PasswordChar = '\0';
- this.materialSingleLineTextField1.SelectedText = "";
- this.materialSingleLineTextField1.SelectionLength = 0;
- this.materialSingleLineTextField1.SelectionStart = 0;
- this.materialSingleLineTextField1.Size = new System.Drawing.Size(231, 23);
- this.materialSingleLineTextField1.TabIndex = 6;
- this.materialSingleLineTextField1.TabStop = false;
- this.materialSingleLineTextField1.UseSystemPasswordChar = false;
- this.materialSingleLineTextField1.TextChanged += new System.EventHandler(this.materialSingleLineTextField1_TextChanged);
- //
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(743, 596);
- this.Controls.Add(this.tableLayoutPanel1);
+ this.ClientSize = new System.Drawing.Size(1024, 768);
+ this.Controls.Add(this.karaokeMP4Player);
+ this.Controls.Add(this.karaokeCDGPlayer);
this.Name = "MainForm";
this.Text = "Karaoke Player";
- this.tableLayoutPanel1.ResumeLayout(false);
- this.tableLayoutPanel1.PerformLayout();
- this.flowLayoutPanel1.ResumeLayout(false);
- this.splitContainer1.Panel1.ResumeLayout(false);
- this.splitContainer1.Panel2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
- this.splitContainer1.ResumeLayout(false);
- this.tableLayoutPanel2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
- private MaterialSkin.Controls.MaterialRaisedButton btnPlay;
- private MaterialSkin.Controls.MaterialRaisedButton btnBrowse;
- private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
- private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
- private System.Windows.Forms.FolderBrowserDialog browseDialog;
- private System.Windows.Forms.SplitContainer splitContainer1;
private KaraokeVideoPlayer karaokeCDGPlayer;
private KaraokeVideoPlayer karaokeMP4Player;
- 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 aac7ec3..3672bea 100644
--- a/KaraokePlayer/MainForm.cs
+++ b/KaraokePlayer/MainForm.cs
@@ -5,18 +5,21 @@ using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
-using Herse.Models;
using System.IO.Compression;
+using System.Windows.Forms;
+using KaraokePlayer.Interfaces;
+using KaraokePlayer.Classes;
+using System.Threading.Tasks;
namespace KaraokePlayer
{
- public partial class MainForm : MaterialForm
+ public partial class MainForm : Form
{
- HerseDb db = new HerseDb();
- private readonly MaterialSkinManager _materialSkinManager;
- private List _fileList;
- private Song currentSong = null;
+ private SongInfoForm songInfoForm = new SongInfoForm();
+ private delegate void Action();
private KaraokeVideoPlayer currentPlayer = null;
+ private IController controller;
+ private ISong currentSong;
public MainForm()
{
InitializeComponent();
@@ -24,78 +27,96 @@ namespace KaraokePlayer
karaokeMP4Player.setup(false, true);
karaokeCDGPlayer.songEndedHandler += new KaraokePlayer.KaraokeVideoPlayer.SongEndedEventHandler(this.karaokePlayerSongEnded);
karaokeMP4Player.songEndedHandler += new KaraokePlayer.KaraokeVideoPlayer.SongEndedEventHandler(this.karaokePlayerSongEnded);
- // Initialize MaterialSkinManager
- _materialSkinManager = MaterialSkinManager.Instance;
- _materialSkinManager.AddFormToManage(this);
- //_materialSkinManager.Theme = new DarkTheme();
- _materialSkinManager.ColorScheme = new ColorScheme(Primary.Green600, Primary.Green700, Primary.Green200, Accent.Red100, TextShade.WHITE);
+
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ this.WindowState = FormWindowState.Maximized;
+ this.ShowInTaskbar = false;
+ karaokeCDGPlayer.Dock = DockStyle.Fill;
+ karaokeMP4Player.Dock = DockStyle.Fill;
+
+ controller = new FirebaseController(
+ stateChanged: (args) =>
+ {
+ if(args.State == Enums.PlayerState.Play)
+ {
+ this.Invoke(new Action(()=> { play(); }));
+ }
+ else if (args.State == Enums.PlayerState.Pause)
+ {
+ this.Invoke(new Action(() => { pause(); }));
+ }
+ else if (args.State == Enums.PlayerState.Next)
+ {
+ this.Invoke(new Action(() => { next(); }));
+ }
+ else
+ {
+ this.Invoke(new Action(() => { stop(); }));
+ }
+ },
+ songChanged: (args) =>
+ {
+ this.Invoke(new Action(() => { stop(); }));
+ currentSong = args.Song;
+ this.Invoke(new Action(() => { previewSong(); }));
+ }
+ );
}
- private void materialRaisedButton1_Click(object sender, System.EventArgs e)
+ private async void previewSong()
{
- playSelectedFile();
+ songInfoForm.Update(currentSong);
+ songInfoForm.Show();
+ await Task.Delay(TimeSpan.FromSeconds(5));
+ controller.Play();
+ songInfoForm.Hide();
}
- private void btnBrowse_Click(object sender, EventArgs e)
+ private void karaokePlayerSongEnded(object sender, EventArgs e)
{
- if (browseDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ next();
+ }
+
+ private void next()
+ {
+ controller.RemoveSong(currentSong);
+ controller.GetNextSong();
+ }
+
+ private void stop()
+ {
+ if (currentPlayer == null) return;
+ currentPlayer.Stop();
+ }
+ private void pause()
+ {
+ if (currentPlayer == null) return;
+ currentPlayer.Pause();
+ }
+
+ private void play()
+ {
+ if (currentSong == null) return;
+ if (currentPlayer != null && currentPlayer.isPaused)
{
- 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 => CreateSongForPath(file)).ToList();
- materialListBox1.DataSource = _fileList;
- materialListBox1.DisplayMember = "Description";
-
+ currentPlayer.Resume();
+ return;
}
- }
-
- private void materialListBox1_MouseDoubleClick(object sender, System.Windows.Forms.MouseEventArgs e)
- {
- int index = this.materialListBox1.IndexFromPoint(e.Location);
- if (index != System.Windows.Forms.ListBox.NoMatches)
- {
- playSelectedFile();
- }
- }
-
- private void materialSingleLineTextField1_TextChanged(object sender, EventArgs e)
- {
- materialListBox1.DataSource = _fileList.Where(
- file => Regex.IsMatch(file.FullPath, materialSingleLineTextField1.Text, RegexOptions.IgnoreCase)).ToList();
- }
-
- public static string[] GetFiles(string path, string searchPattern, SearchOption searchOption)
- {
- string[] searchPatterns = searchPattern.Split('|');
- List files = new List();
- foreach (string sp in searchPatterns)
- files.AddRange(System.IO.Directory.GetFiles(path, sp, searchOption));
- files.Sort();
- return files.ToArray();
- }
-
- public void playSelectedFile()
- {
- btnStop_Click(null, null);
-
- Song file = (Song)materialListBox1.SelectedItem;
- currentSong = file;
- if (file.Extension == ".cdg")
+ if (currentSong.FileType == Enums.FileType.CDG)
{
currentPlayer = karaokeCDGPlayer;
- karaokeCDGPlayer.Play(new Uri(Path.ChangeExtension(file.FullPath, ".mp3")));
+ karaokeCDGPlayer.Play(new Uri(Path.ChangeExtension(currentSong.Path, ".mp3")));
karaokeCDGPlayer.Visible = true;
karaokeMP4Player.Visible = false;
karaokeMP4Player.Stop();
}
- else if (file.Extension == ".zip")
+ else if (currentSong.FileType == Enums.FileType.ZIP)
{
string playPath = null;
string extractPath = Path.Combine(Directory.GetCurrentDirectory(), "temp");
DeleteDirectory(extractPath);
Directory.CreateDirectory(extractPath);
- using (ZipArchive archive = ZipFile.OpenRead(file.FullPath))
+ using (ZipArchive archive = ZipFile.OpenRead(currentSong.Path))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
@@ -117,31 +138,14 @@ namespace KaraokePlayer
}
else {
currentPlayer = karaokeMP4Player;
- karaokeMP4Player.Play(new Uri(file.FullPath));
+ karaokeMP4Player.Play(new Uri(currentSong.Path));
karaokeMP4Player.Visible = true;
karaokeCDGPlayer.Visible = false;
karaokeCDGPlayer.Stop();
}
}
-
- public void karaokePlayerSongEnded(object sender, EventArgs e)
- {
- //here
- }
-
- private void btnStop_Click(object sender, EventArgs e)
- {
- if (currentPlayer == null) return;
- currentPlayer.Stop();
- }
-
- private Song CreateSongForPath(string path)
- {
- Song song = new Song(path);
- return song;
- }
-
- public void DeleteDirectory(string target_dir)
+
+ private void DeleteDirectory(string target_dir)
{
if (!Directory.Exists(target_dir)) { return; }
string[] files = Directory.GetFiles(target_dir);
@@ -160,12 +164,5 @@ namespace KaraokePlayer
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/SongInfoForm.Designer.cs b/KaraokePlayer/SongInfoForm.Designer.cs
new file mode 100644
index 0000000..b1d5998
--- /dev/null
+++ b/KaraokePlayer/SongInfoForm.Designer.cs
@@ -0,0 +1,67 @@
+using KaraokePlayer.Interfaces;
+
+namespace KaraokePlayer
+{
+ partial class SongInfoForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.previewLabel = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // previewLabel
+ //
+ this.previewLabel.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.previewLabel.Font = new System.Drawing.Font("Century Gothic", 60F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.previewLabel.ForeColor = System.Drawing.SystemColors.ControlLightLight;
+ this.previewLabel.Location = new System.Drawing.Point(0, 0);
+ this.previewLabel.Margin = new System.Windows.Forms.Padding(3, 100, 3, 0);
+ this.previewLabel.Name = "previewLabel";
+ this.previewLabel.Padding = new System.Windows.Forms.Padding(0, 100, 0, 0);
+ this.previewLabel.Size = new System.Drawing.Size(1008, 729);
+ this.previewLabel.TabIndex = 0;
+ this.previewLabel.Text = "This is the first line\r\n\r\nAnd this is the second line.";
+ this.previewLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
+ //
+ // SongInfoForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.BackColor = System.Drawing.Color.Black;
+ this.ClientSize = new System.Drawing.Size(1008, 729);
+ this.Controls.Add(this.previewLabel);
+ this.Name = "SongInfoForm";
+ this.Text = "SongInfoForm";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label previewLabel;
+ }
+}
\ No newline at end of file
diff --git a/KaraokePlayer/SongInfoForm.cs b/KaraokePlayer/SongInfoForm.cs
new file mode 100644
index 0000000..7528062
--- /dev/null
+++ b/KaraokePlayer/SongInfoForm.cs
@@ -0,0 +1,29 @@
+using KaraokePlayer.Interfaces;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace KaraokePlayer
+{
+ public partial class SongInfoForm : Form
+ {
+ public SongInfoForm()
+ {
+ InitializeComponent();
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+ this.WindowState = FormWindowState.Maximized;
+ this.ShowInTaskbar = false;
+ }
+
+ public void Update(ISong song)
+ {
+ previewLabel.Text = "Up Next:" + "\r\n\r\n" + song.Artist + "\r\n\r\n\r\n" + song.Title;
+ }
+ }
+}
diff --git a/KaraokePlayer/SongInfoForm.resx b/KaraokePlayer/SongInfoForm.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/KaraokePlayer/SongInfoForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/KaraokePlayer/packages.config b/KaraokePlayer/packages.config
index 5e2b87f..d767685 100644
--- a/KaraokePlayer/packages.config
+++ b/KaraokePlayer/packages.config
@@ -1,6 +1,11 @@
+
+
+
+
+
\ No newline at end of file