aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/ShiftOSAudioProvider.cs
diff options
context:
space:
mode:
authorwilliam341 <[email protected]>2017-05-28 12:37:00 -0700
committerGitHub <[email protected]>2017-05-28 12:37:00 -0700
commit771c20cfb3a703e0f1550fdcf9eb07b78298c944 (patch)
tree59cb532e15ebff313fdba2be264d78ec0033f407 /ShiftOS.WinForms/ShiftOSAudioProvider.cs
parent496b0cbf8659c99203f48210fd39c572400ae623 (diff)
parentc7ba7d733c756d196f98dd4533289a1ef4db715f (diff)
downloadshiftos_thereturn-771c20cfb3a703e0f1550fdcf9eb07b78298c944.tar.gz
shiftos_thereturn-771c20cfb3a703e0f1550fdcf9eb07b78298c944.tar.bz2
shiftos_thereturn-771c20cfb3a703e0f1550fdcf9eb07b78298c944.zip
Merge pull request #1 from shiftos-game/master
welp, no longer a dev.
Diffstat (limited to 'ShiftOS.WinForms/ShiftOSAudioProvider.cs')
-rw-r--r--ShiftOS.WinForms/ShiftOSAudioProvider.cs22
1 files changed, 17 insertions, 5 deletions
diff --git a/ShiftOS.WinForms/ShiftOSAudioProvider.cs b/ShiftOS.WinForms/ShiftOSAudioProvider.cs
index 27c0e5f..fccc76a 100644
--- a/ShiftOS.WinForms/ShiftOSAudioProvider.cs
+++ b/ShiftOS.WinForms/ShiftOSAudioProvider.cs
@@ -39,8 +39,13 @@ namespace ShiftOS.WinForms
{
get
{
- var wc = new System.Net.WebClient();
- return JsonConvert.DeserializeObject<List<string>>(wc.DownloadString("http://getshiftos.ml/api.php?q=soundtrack")).Count;
+ System.Net.WebClient wc = new System.Net.WebClient();
+ try {
+ string result = wc.DownloadString("http://getshiftos.ml/api.php?q=soundtrack");
+ return JsonConvert.DeserializeObject<List<string>>(result).Count;
+ } catch {
+ return JsonConvert.DeserializeObject<List<string>>("[]").Count;
+ }
}
}
@@ -73,10 +78,17 @@ namespace ShiftOS.WinForms
public byte[] GetTrack(int index)
{
- var wc = new System.Net.WebClient();
- var st = JsonConvert.DeserializeObject<List<string>>(wc.DownloadString("http://getshiftos.ml/api.php?q=soundtrack"));
+ System.Net.WebClient wc = new System.Net.WebClient();
+
+ try {
+ string result = wc.DownloadString("http://getshiftos.ml/api.php?q=soundtrack");
- return wc.DownloadData(st[index]);
+ var st = JsonConvert.DeserializeObject<List<string>>(result);
+
+ return wc.DownloadData(st[index]);
+ } catch {
+ return null;
+ }
}
}