From 200648676f2c66691f14097aa89cdd3e09827c7b Mon Sep 17 00:00:00 2001 From: Jimmy Appelt Date: Sat, 10 Oct 2015 20:51:21 +0200 Subject: [PATCH] Added two methods issue #47 --- SpotifyAPI/Local/Models/Track.cs | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/SpotifyAPI/Local/Models/Track.cs b/SpotifyAPI/Local/Models/Track.cs index cda2dc3e..de2c4ecb 100644 --- a/SpotifyAPI/Local/Models/Track.cs +++ b/SpotifyAPI/Local/Models/Track.cs @@ -75,6 +75,7 @@ namespace SpotifyAPI.Local.Models } return ""; } + /// /// Returns a Bitmap of the album cover in the provided size asynchronous /// @@ -95,6 +96,24 @@ namespace SpotifyAPI.Local.Models } } } + + /// + /// Returns a byte[] of the the album cover in the provided size asynchronous + /// + /// AlbumArtSize (160,320,640) + /// A byte[], which is the albumart in binary data + public async Task GetAlbumArtAsByteArrayAsync(AlbumArtSize size) + { + using (WebClient wc = new WebClient()) + { + wc.Proxy = null; + String url = GetAlbumArtUrl(size); + if (url == "") + return null; + return await wc.DownloadDataTaskAsync(url); + } + } + /// /// Returns a Bitmap of the album cover in the provided size /// @@ -115,5 +134,22 @@ namespace SpotifyAPI.Local.Models } } } + + /// + /// Returns a byte[] of the album cover in the provided size + /// + /// AlbumArtSize (160,320,640) + /// A byte[], which is the albumart in binary data + 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); + } + } } }