-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
43 lines (28 loc) · 1.22 KB
/
Program.cs
File metadata and controls
43 lines (28 loc) · 1.22 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
// See https://aka.ms/new-console-template for more information
using System.Diagnostics;
using AtemSharp;
using Microsoft.Extensions.DependencyInjection;
var serviceProvider = new ServiceCollection().AddAtemSharp().BuildServiceProvider();
var lib = serviceProvider.GetRequiredService<IAtemSharpLibrary>();
Console.WriteLine("=== AtemSharp Demo ===\n");
var emergencyCts = new CancellationTokenSource();
if (!Debugger.IsAttached)
{
emergencyCts.CancelAfter(TimeSpan.FromSeconds(20));
}
Console.CancelKeyPress += (_, _) => emergencyCts.Cancel();
var atem = lib.CreateAtemSwitcher("192.168.178.69");
Console.WriteLine("Connecting...");
await atem.ConnectAsync(cancellationToken: emergencyCts.Token);
Console.WriteLine($"Executing Macro {atem.Macros[0].Name} ...");
await atem.Macros[0].Run();
Console.WriteLine("Disconnecting...");
await atem.DisconnectAsync();
Console.WriteLine("Waiting 2s before reconnecting...");
await Task.Delay(TimeSpan.FromSeconds(2));
Console.WriteLine("Reconnecting...");
await atem.ConnectAsync( cancellationToken: emergencyCts.Token);
Console.WriteLine($"Executing Macro {atem.Macros[1].Name} ...");
await atem.Macros[1].Run();
Console.WriteLine("Disconnecting...");
await atem.DisconnectAsync();