Skip to content

Commit

Permalink
Merge pull request #49 from JimmyAppelt/master
Browse files Browse the repository at this point in the history
Added GetAlbumArtAsByteArrayAsync and GetAlbumArtAsByteArray, Closes #47
  • Loading branch information
JohnnyCrazy committed Oct 15, 2015
2 parents 5c3c354 + 2006486 commit bc384b8
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions SpotifyAPI/Local/Models/Track.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public String GetAlbumArtUrl(AlbumArtSize size)
}
return "";
}

/// <summary>
/// Returns a Bitmap of the album cover in the provided size asynchronous
/// </summary>
Expand All @@ -95,6 +96,24 @@ public async Task<Bitmap> GetAlbumArtAsync(AlbumArtSize size)
}
}
}

/// <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>
/// Returns a Bitmap of the album cover in the provided size
/// </summary>
Expand All @@ -115,5 +134,22 @@ public Bitmap GetAlbumArt(AlbumArtSize size)
}
}
}

/// <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);
}
}
}
}

0 comments on commit bc384b8

Please sign in to comment.