//Recording stop and sleep and start async Task ReRecord() { BeginInvoke((MethodInvoker) async delegate { //stop _obs.Api.ToggleRecording(); LimitTimer.Stop(); ReloadAddTime(); while (IsRecording) { //IsRecording await Task.Delay(1000); } _obs.Api.ToggleRecording(); }); }
//Recording method private void onRecordingStateChange(ObsWebSocket sender, OutputState newState) { try { var state = ""; var btnstate = ""; switch (newState) { case OutputState.Starting: state = "録画開始中..."; btnstate = "開始中..."; break; case OutputState.Started: state = "録画中"; btnstate = "録画停止"; //Start Timer BeginInvoke((MethodInvoker)delegate { //LeftStoppingTimeSec = 5; LimitTimer.Start(); IsRecording = true; }); break; case OutputState.Stopping: state = "録画停止中..."; btnstate = "停止中..."; break; case OutputState.Stopped: state = "停止"; btnstate = "録画開始"; //Reset AddTme BeginInvoke((MethodInvoker)delegate { LimitTimer.Stop(); ReloadAddTime(); IsRecording = false; }); break; default: state = "不明"; //Reset AddTme BeginInvoke((MethodInvoker)delegate { LimitTimer.Stop(); ReloadAddTime(); }); break; } BeginInvoke((MethodInvoker)delegate { RecordingStatus.Text = state; recordbtn.Text = btnstate; if (state == "不明") recordbtn.Enabled = false; }); } catch { } }