forked from shanselman/PowerPointToOBSSceneSwitcher
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOBS.cs
70 lines (59 loc) · 1.3 KB
/
OBS.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
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
68
69
70
using OBS.WebSocket.NET;
using System;
using System.Threading.Tasks;
namespace PowerPointToOBSSceneSwitcher
{
public class ObsLocal : IDisposable
{
private bool _DisposedValue;
private ObsWebSocket _OBS;
public ObsLocal() { }
public Task Connect()
{
_OBS = new ObsWebSocket();
_OBS.Connect($"ws://127.0.0.1:4444", "");
return Task.CompletedTask;
}
public bool ChangeScene(string scene)
{
_OBS.Api.SetCurrentScene(scene);
return true;
}
public bool StartRecording()
{
try { _OBS.Api.StartRecording(); }
catch { /* Recording already started */ }
return true;
}
public bool StopRecording()
{
try { _OBS.Api.StopRecording(); }
catch { /* Recording already stopped */ }
return true;
}
protected virtual void Dispose(bool disposing)
{
if (!_DisposedValue)
{
if (disposing)
{
// TODO: dispose managed state (managed objects)
}
_OBS.Disconnect();
_OBS = null;
_DisposedValue = true;
}
}
~ObsLocal()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: false);
}
public void Dispose()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}
}