Skip to content

Commit a779063

Browse files
author
Johnny @PC
committed
Changed WebClient handling/Added Exceptions
1 parent 39fe7ed commit a779063

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎SpotifyAPI.dll‎

-512 Bytes
Binary file not shown.

‎SpotifyAPI/Track.cs‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ public async Task<Bitmap> GetAlbumArtAsync(AlbumArtSize size)
8888
String url = GetAlbumArtURL(size);
8989
if (url == "")
9090
return new Bitmap(640, 640);
91-
byte[] stream = null;
91+
byte[] data = null;
9292
try
9393
{
94-
stream = await wc.DownloadDataTaskAsync(url);
94+
data = await wc.DownloadDataTaskAsync(url);
9595
}
9696
catch(WebException e)
9797
{
98-
stream = wc.DownloadData(@"http://www.51allout.co.uk/wp-content/uploads/2012/02/Image-not-found.gif");
98+
throw;
9999
}
100-
using (MemoryStream ms = new MemoryStream(stream))
100+
using (MemoryStream ms = new MemoryStream(data))
101101
{
102102
return (Bitmap)Image.FromStream(ms);
103103
}
@@ -111,7 +111,16 @@ public Bitmap GetAlbumArt(AlbumArtSize size)
111111
String url = GetAlbumArtURL(size);
112112
if (url == "")
113113
return new Bitmap(640,640);
114-
using (MemoryStream ms = new MemoryStream(wc.DownloadData(url)))
114+
byte[] data = null;
115+
try
116+
{
117+
data = wc.DownloadData(url);
118+
}
119+
catch (WebException e)
120+
{
121+
throw;
122+
}
123+
using (MemoryStream ms = new MemoryStream(data))
115124
{
116125
return (Bitmap)Image.FromStream(ms);
117126
}

0 commit comments

Comments
 (0)