This repository has been archived on 2025-01-01. You can view files and clone it, but cannot push or open issues or pull requests.
ShiftOS_TheReturn/ShiftOS.WinForms/ShiftOSAudioProvider.cs

58 lines
1.4 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
2017-02-02 09:47:23 -05:00
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using ShiftOS.Engine;
namespace ShiftOS.WinForms
{
class ShiftOSAudioProvider : IAudioProvider
{
public int Count
{
get
{
var wc = new System.Net.WebClient();
return JsonConvert.DeserializeObject<List<string>>(wc.DownloadString("http://getshiftos.ml/api.php?q=soundtrack")).Count;
}
}
public float Volume
{
get
{
2017-02-02 09:47:23 -05:00
if (SaveSystem.CurrentSave == null)
return 1.0f;
try
{
return SaveSystem.CurrentSave.Settings.audioVolume;
}
catch
{
SaveSystem.CurrentSave.Settings.audioVolume = 1.0f;
return 1.0f;
}
}
set
{
2017-02-02 09:47:23 -05:00
SaveSystem.CurrentSave.Settings.audioVolume = value;
}
}
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"));
return wc.DownloadData(st[index]);
}
}
}