/// <summary> /// 停止录屏 /// </summary> /// <returns></returns> public static ScreenRecorderResult StopRecording(Window windowOwner = null) { int checkCount = 0; string recordFilePath = GetRecordFilePath(); while (true) { if (checkCount > 10) { break; } if (AppUtils.GetFileSizeSafe(recordFilePath) < 2048) { Thread.Sleep(200); checkCount++; } else { break; } } ScreenRecorderResult ret = _screenRecorder.StopRecord(); string microName = string.Empty; if (!string.IsNullOrWhiteSpace(recordFilePath)) { string tempFileName = System.IO.Path.GetFileName(recordFilePath); microName = Path.GetFileNameWithoutExtension(tempFileName); } bool needSaveWindow = false; if (needSaveWindow) { RecordSaveWin win = new RecordSaveWin(); if (windowOwner != null) { win.Owner = windowOwner; } win.SaveFileNameTbox.Text = microName; win.ShowDialog(); win.SaveRecordAndDeleteFile(); } else { RecordSaveWin.SaveRecordAndDeleteFile(microName); } InvokeRecordStateChanged(RecordStatus.RecordComplete); _recordingToolWin?.Close(); _recordingToolWin = null; EmptyRecordFilePath(); return(ret); }
/// <summary> /// 开始录屏(录屏工具录屏) /// </summary> public static void StartRecord(Window windowOwner = null) { AppUtils.Owner = windowOwner; bool success = AppUtils.CheckDisk(); if (!success) { InvokeRecordStateChanged(RecordStatus.NoRecord); return; } bool isAudioInputDeviceEnable = IsAudioInputDeviceEnable(); bool isAudioOutputDeviceEnable = IsAudioOutputDeviceEnable(); if (!(isAudioInputDeviceEnable && isAudioOutputDeviceEnable)) { var res = MessageBox.Show(null, "没有音频设备,是否继续录制?", "提示"); if (res != MessageBoxResult.OK) { InvokeRecordStateChanged(RecordStatus.NoRecord); return; } } ShowRecordCountDown(windowOwner); var ret = StartRecording(); if (ret != ScreenRecorderResult.Success) { // 开始录课失败 } StartRecordTime = DateTime.Now; _recordingToolWin = new RecordingToolWin(); _recordingToolWin.Owner = windowOwner; _recordingToolWin.Show(); }