Advertisement
Guest User

sevizio

a guest
May 19th, 2021
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. using System;
  2. using System.Threading.Tasks;
  3. using OBS_IRL_STREAM.Models.Entities;
  4. using OBSWebsocketDotNet;
  5.  
  6. namespace OBS_IRL_STREAM.Models.Services.Application
  7. {
  8. public class OBSService : IOBSService
  9. {
  10. protected OBSWebsocket _obs = new OBSWebsocket();
  11.  
  12. public void SetOBS(OBSWebsocket _obs)
  13. {
  14. this._obs = _obs;
  15. }
  16.  
  17. public Task ConnectOBS(string ip, string password)
  18. {
  19. try
  20. {
  21. if(!_obs.IsConnected)
  22. {
  23. _obs.Connect(ip, password);
  24. }
  25. }
  26. catch(Exception e)
  27. {
  28. Console.WriteLine(e);
  29. }
  30. return null;
  31. }
  32.  
  33. public Task ToggleStreamOBS()
  34. {
  35. try
  36. {
  37. if(_obs.IsConnected)
  38. {
  39. _obs.ToggleStreaming();
  40. }
  41. }
  42. catch(Exception e)
  43. {
  44. Console.WriteLine(e);
  45. }
  46. return null;
  47. }
  48.  
  49. public Task ToggleRecordingOBS()
  50. {
  51. try
  52. {
  53. if(_obs.IsConnected)
  54. {
  55. _obs.ToggleRecording();
  56. }
  57. }
  58. catch(Exception e)
  59. {
  60. Console.WriteLine(e);
  61. }
  62. return null;
  63. }
  64.  
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement