aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/ShiftOSAudioProvider.cs
blob: f21732568e728c9b5514e3fde0bed0498868f67f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
            }
        }

        private float _vol = 1.0f;

        public float Volume
        {
            get
            {
                return _vol;
            }

            set
            {
                _vol = 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]);
        }
    }

    
}