Implemented some API functions
This commit is contained in:
@@ -29,12 +29,46 @@ namespace MusicPlayer
|
||||
|
||||
public List<Artist> GetArtists()
|
||||
{
|
||||
return null;
|
||||
List<Artist> artistlist = new List<Artist>();
|
||||
|
||||
JObject o = nw.SendString("getartists?id=hallo");
|
||||
if (o["result"].ToString() == "OK")
|
||||
{
|
||||
for (int i = 0; i < o["artists"].Count(); i++) {
|
||||
artistlist.Add(new Artist(o["artists"][i][0].ToString()));
|
||||
}
|
||||
}
|
||||
return artistlist;
|
||||
}
|
||||
|
||||
public List<Album> GetAlbums()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<Album> albumlist = new List<Album>();
|
||||
|
||||
JObject o = nw.SendString("getalbums?id=hallo");
|
||||
if (o["result"].ToString() == "OK")
|
||||
{
|
||||
for (int i = 0; i < o["albums"].Count(); i++)
|
||||
{
|
||||
albumlist.Add(new Album(o["albums"][i][0].ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
return albumlist;
|
||||
}
|
||||
|
||||
public List<Year> GetYears()
|
||||
{
|
||||
List<Year> yearlist = new List<Year> ();
|
||||
JObject o = nw.SendString("getyears?id=hallo");
|
||||
if (o["result"].ToString() == "OK")
|
||||
{
|
||||
for (int i = 0; i < o["years"].Count(); i++)
|
||||
{
|
||||
yearlist.Add(new Year(o["years"][i][0].ToString()));
|
||||
}
|
||||
}
|
||||
return yearlist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
<Compile Include="SongsTable.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Year.cs" />
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
@@ -17,6 +17,18 @@ namespace MusicPlayer
|
||||
NetworkHandler nw = new NetworkHandler("http://www.imegumii.nl");
|
||||
APIHandler api = new APIHandler(nw);
|
||||
Console.WriteLine(api.GetSongURLByID("102"));
|
||||
api.GetArtists().ForEach(a =>
|
||||
{
|
||||
Console.WriteLine(a.naam);
|
||||
});
|
||||
api.GetYears().ForEach(y =>
|
||||
{
|
||||
Console.WriteLine(y.year);
|
||||
});
|
||||
api.GetAlbums().ForEach(a =>
|
||||
{
|
||||
Console.WriteLine(a.albumnaam);
|
||||
});
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new MainForm());
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace MusicPlayer
|
||||
{
|
||||
public class Year
|
||||
{
|
||||
public string year { get; set; }
|
||||
|
||||
public Year(string year)
|
||||
{
|
||||
this.year = year;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user