public Uri GetMusicFile(string id)
{
using (HttpClient client = new HttpClient())
{
HttpResponseMessage response = client.GetAsync("https://api.soundcloud.com/tracks/" + id + "/streams?client_id=" + ClientId).Result;
if (response.IsSuccessStatusCode)
{
ApiResponse apiResponse = new ApiResponse
{
Data = JsonConvert.DeserializeObject<dynamic>(AsyncHelper.RunSync(() => response.Content.ReadAsStringAsync()))
};
string mp3;
try
{
mp3 = apiResponse.Data["http_mp3_128_url"].ToString();
}
catch (Exception)
{
try
{
mp3 = apiResponse.Data["hls_mp3_128_url"].ToString();
UpdateToastMessage("Sorry, we can't play this song. It uses the HLS protocol, and the app does not support it yet.");
}
catch (Exception ex)
{
ErrorLogProxy.LogError(ex.ToString());
ErrorLogProxy.NotifyErrorInDebug(ex.ToString());
return null;
}
}
return new Uri(mp3);
}
}
return null;
}
void UpdateToastMessage(string message)