Explorar el Código

Merge remote-tracking branch 'origin/gui' into gui

Conflicts:
	MusicPlayer/MusicPlayer/MainForm.Designer.cs
	MusicPlayer/MusicPlayer/MainForm.cs
Kenneth van Ewijk hace 10 años
padre
commit
c2afd44654

+ 36 - 1
MusicPlayer/MusicPlayer/APIHandler.cs

@@ -24,7 +24,42 @@ namespace MusicPlayer
                 return o["songurl"].ToString();
             }
             return o["errormsg"].ToString();
-        } 
+        }
+
+        public List<Song> GetSongsByAlbum(string albumname)
+        {
+            return GetSongsByArgs("album=" + albumname);
+        }
+
+        public List<Song> GetSongsByArtist(string artistname)
+        {
+            return GetSongsByArgs("artist=" + artistname);
+        }
+
+        public List<Song> GetSongsByGenre(string genre)
+        {
+            return GetSongsByArgs("genre=" + genre);
+        }
+
+        public List<Song> GetSongsByYear(string year)
+        {
+            return GetSongsByArgs("album=" + year);
+        }
+
+        public List<Song> GetSongsByArgs(string args)
+        {
+            List<Song> songslist = new List<Song>();
+            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<Artist> GetArtists()
         {

+ 26 - 11
MusicPlayer/MusicPlayer/Main.cs

@@ -31,21 +31,36 @@ namespace MusicPlayer
 
         private void Populate()
         {
-            table.Add(new Song("102", "Test Song 1", "Test Album 1", "Test Artist 1", api));
+            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);
 
-            form.GenreListBox.Items.Add("Hardcore");
-            form.GenreListBox.Items.Add("Hardstyle");
-            form.GenreListBox.Items.Add("Pop");
+            }
+            
+            table.Add(new Song("102", "Test Song 1", "Test Album 1", "Test Artist 1", api));
+      
+            table.Add(new Song("104", "Test Song 2", "Test Album 2", "Test Artist 2", api));
+        }
 
-            form.ArtistListBox.Items.Add("Kygo");
-            form.ArtistListBox.Items.Add("Monstercat");
-            form.ArtistListBox.Items.Add("Mozart");
+        public void ArtistFilter(string artist)
+        {
+            System.Console.Write(artist);
+        }
 
-            form.AlbumListView.Items.Add("Album 1");
-            form.AlbumListView.Items.Add("Album 2");
-            form.AlbumListView.Items.Add("Album 3");
+        public void AlbumFilter(string album)
+        {
+            System.Console.Write(album);
 
-            table.Add(new Song("104", "Test Song 2", "Test Album 2", "Test Artist 2", api));
         }
     }
+
 }
+
+

+ 22 - 18
MusicPlayer/MusicPlayer/MainForm.Designer.cs

@@ -41,14 +41,14 @@
             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.BufferBar = new System.Windows.Forms.ProgressBar();
             this.PositionBar = new System.Windows.Forms.ProgressBar();
             this.BufferLabel = new System.Windows.Forms.Label();
             this.PositionLabel = new System.Windows.Forms.Label();
             this.UpdateTimer = new System.Windows.Forms.Timer(this.components);
+            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();
@@ -75,6 +75,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
@@ -86,6 +87,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
             // 
@@ -98,6 +100,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
             // 
@@ -108,6 +111,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
             // 
@@ -179,15 +183,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
             // 
@@ -199,15 +203,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);
             // 
             // BufferBar
             // 

+ 23 - 0
MusicPlayer/MusicPlayer/MainForm.cs

@@ -57,10 +57,33 @@ namespace MusicPlayer
             main.audio.Stop();
         }
 
+
         private void UpdateTimer_Tick(object sender, EventArgs e)
         {
             BufferBar.Value = main.audio.Buffered;
             PositionBar.Value = main.audio.Position;
         }
+
+        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);
+
+        }
     }
 }

+ 16 - 0
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);
 

+ 12 - 0
README.md

@@ -0,0 +1,12 @@
+# musicplayer
+
+##Onderdelen
+- Server/Client
+- Threading/Threadpools
+- File IO
+- Socket communicatie
+- Klasse Structuur
+- Forms Applicatie
+- Specifieke C# - Delegates/Lambda...
+
+