ソースを参照

Merge refs/heads/developer into refs/heads/gui

Janco Kock 10 年 前
コミット
2ddbe6e9c8
3 ファイル変更64 行追加1 行削除
  1. 36 1
      MusicPlayer/MusicPlayer/APIHandler.cs
  2. 16 0
      MusicPlayer/MusicPlayer/Program.cs
  3. 12 0
      README.md

+ 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()
         {

+ 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...
+
+