-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathRecorderHarness.cs
More file actions
67 lines (59 loc) · 2.2 KB
/
RecorderHarness.cs
File metadata and controls
67 lines (59 loc) · 2.2 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using NetCoreAudio;
namespace DemoHarness
{
internal static class RecorderHarness
{
public static async Task InteractWithRecorder()
{
var recorder = new Recorder();
recorder.RecordingFinished += OnRecordingFinished;
ShowFileEntryPrompt();
var fileName = Console.ReadLine();
ShowInstruction();
while (true)
{
var command = Console.ReadLine();
try
{
switch (command)
{
case "record":
Console.WriteLine($"Recording into {fileName}");
await recorder.Record(fileName);
Console.WriteLine(recorder.Recording ? "Recording started" : "Could not start recording");
break;
case "stop":
await recorder.Stop();
Console.WriteLine(!recorder.Recording ? "Recording stopped" : "Could not stop the recording");
break;
case "exit":
break;
default:
Console.WriteLine("Unknown command!");
break;
}
if (command == "exit") break;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
static void ShowFileEntryPrompt()
{
Console.WriteLine("Please enter the full path to the file where you want to store your recording:");
}
static void ShowInstruction()
{
Console.WriteLine("You can manipulate the recorder with the following commands:");
Console.WriteLine("record - Record audio into a file");
Console.WriteLine("stop - Stop the recording");
Console.WriteLine("exit - Exit the app");
}
static void OnRecordingFinished(object sender, EventArgs e)
{
Console.WriteLine("Recording finished");
}
}
}