-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
executable file
·41 lines (38 loc) · 1.2 KB
/
Program.cs
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
using System;
using System.Threading;
using NAudio.Wave;
using System.Collections.Generic;
namespace AudioRouter
{
class Program
{
static void Main(string[] args)
{
AudioRouter.Webserver.StartWebServer();
while(true) {
Thread.Sleep(1000);
}
}
public static Dictionary<string, string> GetDevices() {
Dictionary<string, string> devices = new Dictionary<string, string>();
foreach (var dev in DirectSoundOut.Devices)
{
devices.Add(dev.Guid.ToString(), dev.Description);
}
return devices;
}
public static void PlayOnDevice(string deviceGUID, string filename, string volume) {
var audioFile = new AudioFileReader(filename);
if(volume != null) {
audioFile.Volume = float.Parse(volume);
}
var outputDevice = new DirectSoundOut(Guid.Parse(deviceGUID));
outputDevice.Init(audioFile);
outputDevice.Play();
while (outputDevice.PlaybackState == PlaybackState.Playing)
{
Thread.Sleep(1000);
}
}
}
}