From 853d2f452da13aecb221720988448e7496715482 Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Thu, 29 Oct 2015 19:37:31 +0100 Subject: [PATCH 1/4] Create README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..4e3c74d --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# musicplayer + +##Onderdelen +Server/Client +Threading/Threadpools +File IO +Socket communicatie +Klasse Structuur +Forms Applicatie +Specifieke C# - Delegates/Lambda... + + From 436ae2d96ce09b0e717072dc0d1ce7559fc9b266 Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Thu, 29 Oct 2015 19:38:12 +0100 Subject: [PATCH 2/4] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 4e3c74d..dcb32ad 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # musicplayer ##Onderdelen -Server/Client -Threading/Threadpools -File IO -Socket communicatie -Klasse Structuur -Forms Applicatie -Specifieke C# - Delegates/Lambda... +- Server/Client +- Threading/Threadpools +- File IO +- Socket communicatie +- Klasse Structuur +- Forms Applicatie +- Specifieke C# - Delegates/Lambda... From 6dc28511b1d6bf2c17fc5d5a627d461685979123 Mon Sep 17 00:00:00 2001 From: Yorick Rommers Date: Thu, 29 Oct 2015 22:51:45 +0100 Subject: [PATCH 3/4] Implemented more API functions --- MusicPlayer/MusicPlayer/APIHandler.cs | 37 ++++++++++++++++++++++++++- MusicPlayer/MusicPlayer/Program.cs | 16 ++++++++++++ MusicPlayer/MusicPlayer/Song.cs | 2 +- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/MusicPlayer/MusicPlayer/APIHandler.cs b/MusicPlayer/MusicPlayer/APIHandler.cs index 1468da0..a954496 100644 --- a/MusicPlayer/MusicPlayer/APIHandler.cs +++ b/MusicPlayer/MusicPlayer/APIHandler.cs @@ -24,7 +24,42 @@ namespace MusicPlayer return o["songurl"].ToString(); } return o["errormsg"].ToString(); - } + } + + public List GetSongsByAlbum(string albumname) + { + return GetSongsByArgs("album=" + albumname); + } + + public List GetSongsByArtist(string artistname) + { + return GetSongsByArgs("artist=" + artistname); + } + + public List GetSongsByGenre(string genre) + { + return GetSongsByArgs("genre=" + genre); + } + + public List GetSongsByYear(string year) + { + return GetSongsByArgs("album=" + year); + } + + public List GetSongsByArgs(string args) + { + List songslist = new List(); + JObject o = nw.SendString("getsongs?"+args); + if (o["result"].ToString() == "OK") + { + dynamic songs = o["songs"]; + for (int i = 0; i < songs.Count; i++) + { + songslist.Add(new Song(songs[i][0].ToString(), songs[i][3].ToString(), songs[i][5].ToString(), songs[i][4].ToString(), this)); + } + } + return songslist; + } public List GetArtists() { diff --git a/MusicPlayer/MusicPlayer/Program.cs b/MusicPlayer/MusicPlayer/Program.cs index 78734c8..aca8d84 100644 --- a/MusicPlayer/MusicPlayer/Program.cs +++ b/MusicPlayer/MusicPlayer/Program.cs @@ -19,6 +19,22 @@ namespace MusicPlayer NetworkHandler nw = new NetworkHandler("http://www.imegumii.nl"); APIHandler api = new APIHandler(nw); +// api.GetSongsByArtist("Amon Amarth").ForEach(s => +// { +// Console.WriteLine(s.SongID); +// }); +// api.GetSongsByYear("2009").ForEach(s => +// { +// Console.WriteLine(s.Name); +// }); + api.GetSongsByGenre("Melodic Death Metal").ForEach(s => + { + Console.WriteLine(s.Name); + }); +// api.GetSongsByAlbum("Stronger").ForEach(s => +// { +// Console.WriteLine(s.Name); +// }); MainForm form = new MainForm(); new Main(nw, api, form); diff --git a/MusicPlayer/MusicPlayer/Song.cs b/MusicPlayer/MusicPlayer/Song.cs index 3fb4e5b..a44b6cf 100644 --- a/MusicPlayer/MusicPlayer/Song.cs +++ b/MusicPlayer/MusicPlayer/Song.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace MusicPlayer { - class Song + public class Song { public string SongID { get; set; } public string Name { get; set; } From 85028d04a905dada3a569b210df20e8e77ff0949 Mon Sep 17 00:00:00 2001 From: Janco Kock Date: Thu, 29 Oct 2015 22:29:52 +0100 Subject: [PATCH 4/4] Load data from server into views --- MusicPlayer/MusicPlayer/Main.cs | 41 +++++++++++++------- MusicPlayer/MusicPlayer/MainForm.Designer.cs | 40 ++++++++++--------- MusicPlayer/MusicPlayer/MainForm.cs | 20 ++++++++++ 3 files changed, 70 insertions(+), 31 deletions(-) diff --git a/MusicPlayer/MusicPlayer/Main.cs b/MusicPlayer/MusicPlayer/Main.cs index e49c029..72f650a 100644 --- a/MusicPlayer/MusicPlayer/Main.cs +++ b/MusicPlayer/MusicPlayer/Main.cs @@ -31,21 +31,36 @@ namespace MusicPlayer private void Populate() { + form.AlbumListView.Items.Add(" Alle albums"); + foreach (Album a in this.api.GetAlbums()) + { + form.AlbumListView.Items.Add(a.albumnaam); + + } + form.ArtistListBox.Items.Add("Alle artiesten"); + foreach (Artist a in this.api.GetArtists()) + { + form.ArtistListBox.Items.Add(a.naam); + + } + table.Add(new Song("102", "Test Song 1", "Test Album 1", "Test Artist 1", api)); - - form.GenreListBox.Items.Add("Hardcore"); - form.GenreListBox.Items.Add("Hardstyle"); - form.GenreListBox.Items.Add("Pop"); - - form.ArtistListBox.Items.Add("Kygo"); - form.ArtistListBox.Items.Add("Monstercat"); - form.ArtistListBox.Items.Add("Mozart"); - - form.AlbumListView.Items.Add("Album 1"); - form.AlbumListView.Items.Add("Album 2"); - form.AlbumListView.Items.Add("Album 3"); - + table.Add(new Song("104", "Test Song 2", "Test Album 2", "Test Artist 2", api)); } + + public void ArtistFilter(string artist) + { + System.Console.Write(artist); + } + + public void AlbumFilter(string album) + { + System.Console.Write(album); + + } } + } + + diff --git a/MusicPlayer/MusicPlayer/MainForm.Designer.cs b/MusicPlayer/MusicPlayer/MainForm.Designer.cs index 3f00825..10556f0 100644 --- a/MusicPlayer/MusicPlayer/MainForm.Designer.cs +++ b/MusicPlayer/MusicPlayer/MainForm.Designer.cs @@ -40,9 +40,9 @@ this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ControlsPanel = new System.Windows.Forms.Panel(); - this.PlayButton = new System.Windows.Forms.Button(); - this.PauseButton = new System.Windows.Forms.Button(); this.StopButton = new System.Windows.Forms.Button(); + this.PauseButton = new System.Windows.Forms.Button(); + this.PlayButton = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.SongsTableView)).BeginInit(); this.MainPanel.SuspendLayout(); this.MenuStrip.SuspendLayout(); @@ -69,6 +69,7 @@ this.SongsTableView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.SongsTableView.Size = new System.Drawing.Size(760, 148); this.SongsTableView.TabIndex = 0; + this.SongsTableView.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.SongsTableView_CellDoubleClick); this.SongsTableView.SelectionChanged += new System.EventHandler(this.SongsTableView_SelectionChanged); // // GenreListBox @@ -80,6 +81,7 @@ this.GenreListBox.Size = new System.Drawing.Size(124, 134); this.GenreListBox.Sorted = true; this.GenreListBox.TabIndex = 1; + this.GenreListBox.SelectedIndexChanged += new System.EventHandler(this.GenreListBox_SelectedIndexChanged); // // AlbumListView // @@ -92,6 +94,7 @@ this.AlbumListView.Sorting = System.Windows.Forms.SortOrder.Ascending; this.AlbumListView.TabIndex = 2; this.AlbumListView.UseCompatibleStateImageBehavior = false; + this.AlbumListView.SelectedIndexChanged += new System.EventHandler(this.AlbumListView_SelectedIndexChanged); // // ArtistListBox // @@ -102,6 +105,7 @@ this.ArtistListBox.Size = new System.Drawing.Size(124, 134); this.ArtistListBox.Sorted = true; this.ArtistListBox.TabIndex = 3; + this.ArtistListBox.SelectedIndexChanged += new System.EventHandler(this.ArtistListBox_SelectedIndexChanged); // // MainPanel // @@ -169,15 +173,15 @@ this.ControlsPanel.Size = new System.Drawing.Size(784, 119); this.ControlsPanel.TabIndex = 4; // - // PlayButton + // StopButton // - this.PlayButton.Location = new System.Drawing.Point(12, 13); - this.PlayButton.Name = "PlayButton"; - this.PlayButton.Size = new System.Drawing.Size(75, 23); - this.PlayButton.TabIndex = 0; - this.PlayButton.Text = "Play"; - this.PlayButton.UseVisualStyleBackColor = true; - this.PlayButton.Click += new System.EventHandler(this.PlayButton_Click); + this.StopButton.Location = new System.Drawing.Point(203, 13); + this.StopButton.Name = "StopButton"; + this.StopButton.Size = new System.Drawing.Size(75, 23); + this.StopButton.TabIndex = 2; + this.StopButton.Text = "Stop"; + this.StopButton.UseVisualStyleBackColor = true; + this.StopButton.Click += new System.EventHandler(this.StopButton_Click); // // PauseButton // @@ -189,15 +193,15 @@ this.PauseButton.UseVisualStyleBackColor = true; this.PauseButton.Click += new System.EventHandler(this.PauseButton_Click); // - // StopButton + // PlayButton // - this.StopButton.Location = new System.Drawing.Point(203, 13); - this.StopButton.Name = "StopButton"; - this.StopButton.Size = new System.Drawing.Size(75, 23); - this.StopButton.TabIndex = 2; - this.StopButton.Text = "Stop"; - this.StopButton.UseVisualStyleBackColor = true; - this.StopButton.Click += new System.EventHandler(this.StopButton_Click); + this.PlayButton.Location = new System.Drawing.Point(12, 13); + this.PlayButton.Name = "PlayButton"; + this.PlayButton.Size = new System.Drawing.Size(75, 23); + this.PlayButton.TabIndex = 0; + this.PlayButton.Text = "Play"; + this.PlayButton.UseVisualStyleBackColor = true; + this.PlayButton.Click += new System.EventHandler(this.PlayButton_Click); // // MainForm // diff --git a/MusicPlayer/MusicPlayer/MainForm.cs b/MusicPlayer/MusicPlayer/MainForm.cs index 1a8cae3..64199b5 100644 --- a/MusicPlayer/MusicPlayer/MainForm.cs +++ b/MusicPlayer/MusicPlayer/MainForm.cs @@ -51,5 +51,25 @@ namespace MusicPlayer { main.audio.Stop(); } + private void GenreListBox_SelectedIndexChanged(object sender, EventArgs e) + { + } + + private void ArtistListBox_SelectedIndexChanged(object sender, EventArgs e) + { + if (ArtistListBox.SelectedItems.Count != 0) + main.ArtistFilter(ArtistListBox.SelectedItems[0].ToString()); + } + + private void AlbumListView_SelectedIndexChanged(object sender, EventArgs e) + { + if(AlbumListView.SelectedItems.Count != 0) + main.AlbumFilter(AlbumListView.SelectedItems[0].ToString()); + } + + private void SongsTableView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) + { + main.audio.Play(SongsTableView.CurrentRow.DataBoundItem as Song); + } } }