Added two methods issue #47

This commit is contained in:
Jimmy Appelt 2015-10-10 20:51:21 +02:00
parent f09c52a60c
commit 200648676f

View File

@ -75,6 +75,7 @@ namespace SpotifyAPI.Local.Models
} }
return ""; return "";
} }
/// <summary> /// <summary>
/// Returns a Bitmap of the album cover in the provided size asynchronous /// Returns a Bitmap of the album cover in the provided size asynchronous
/// </summary> /// </summary>
@ -95,6 +96,24 @@ namespace SpotifyAPI.Local.Models
} }
} }
} }
/// <summary>
/// Returns a byte[] of the the album cover in the provided size asynchronous
/// </summary>
/// <param name="size">AlbumArtSize (160,320,640)</param>
/// <returns>A byte[], which is the albumart in binary data</returns>
public async Task<byte[]> GetAlbumArtAsByteArrayAsync(AlbumArtSize size)
{
using (WebClient wc = new WebClient())
{
wc.Proxy = null;
String url = GetAlbumArtUrl(size);
if (url == "")
return null;
return await wc.DownloadDataTaskAsync(url);
}
}
/// <summary> /// <summary>
/// Returns a Bitmap of the album cover in the provided size /// Returns a Bitmap of the album cover in the provided size
/// </summary> /// </summary>
@ -115,5 +134,22 @@ namespace SpotifyAPI.Local.Models
} }
} }
} }
/// <summary>
/// Returns a byte[] of the album cover in the provided size
/// </summary>
/// <param name="size">AlbumArtSize (160,320,640)</param>
/// <returns>A byte[], which is the albumart in binary data</returns>
public byte[] GetAlbumArtAsByteArray(AlbumArtSize size)
{
using (WebClient wc = new WebClient())
{
wc.Proxy = null;
String url = GetAlbumArtUrl(size);
if (url == "")
return null;
return wc.DownloadData(url);
}
}
} }
} }