Пример #1
0
        public void PauseAndResumeRecording()
        {
            if (!RecorderHelper.IsRecording())
            {
                return;
            }

            if (RecorderHelper.IsPausing())
            {
                // 更换暂停按钮图标
                PauseBtn.IsRecording = true;
                ScreenRecorderResult ret = RecorderHelper.ResumeRecording();
                if (ret != ScreenRecorderResult.Success)
                {
                    //MessageBox.Show("");
                }

                //_fileSizeQueryCount = 0;
                _countDownTimer_Elapsed(null, null);
                StartCountDownTimer();
            }
            else
            {
                // 更换暂停按钮图标
                PauseBtn.IsRecording = false;
                ScreenRecorderResult ret = RecorderHelper.PauseRecording();
                if (ret != ScreenRecorderResult.Success)
                {
                    //MessageBox.Show("");
                }

                StopCountDownTimer();
            }
        }
Пример #2
0
        private void _countDownTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            this.Dispatcher.Invoke((Action)(() =>
            {
                TimeSpan timeSpan = RecorderHelper.GetRecordingTime();
                _recordingEllipseColor = !_recordingEllipseColor;

                TimerLb.Text = timeSpan.ToString(@"hh\:mm\:ss");
            }));
        }
Пример #3
0
        public MainPage()
        {
            this.InitializeComponent();

            identificationHelper = new IdentificationHelper();

            RecorderParams = new RecorderParams(2, 0.15f, 10);
            recorderHelper = new RecorderHelper(RecorderParams, this);

            Messages = new ObservableCollection <Message>();
            Speakers = new ObservableCollection <Speaker>();
        }
Пример #4
0
        private static void DeleteRecordFile()
        {
            string recordFilePath = RecorderHelper.GetRecordFilePath();

            if (!string.IsNullOrWhiteSpace(recordFilePath))
            {
                if (System.IO.File.Exists(recordFilePath))
                {
                    System.IO.File.Delete(recordFilePath);
                }
            }
        }
Пример #5
0
        private void RecordKinectAudio()
        {
            lock (lockObj)
            {
                IsRecording = true;

                var source = CreateAudioSource();

                var time = DateTime.Now.ToString("hhmmss");
                _recordingFileName = time + ".wav";
                using (var fileStream =
                           new FileStream(_recordingFileName, FileMode.Create))
                {
                    RecorderHelper.WriteWavFile(source, fileStream);
                }

                IsRecording = false;
            }
        }
Пример #6
0
        private static MethodResult SaveRecordFile(string microCourseName)
        {
            MethodResult mr = new MethodResult();

            mr.Status  = 0;
            mr.Message = "sucess";

            string recordFullFileName = RecorderHelper.GetRecordFilePath();

            if (string.IsNullOrWhiteSpace(recordFullFileName))
            {
                mr.Status  = 2;
                mr.Message = "recordFullFileName is empty";
                return(mr);
            }

            if (!AppUtils.FileExists(recordFullFileName))
            {
                mr.Status  = 3;
                mr.Message = string.Format("{0} is not exist", recordFullFileName);
                return(mr);
            }

            try
            {
                string recordVideoPath = AppUtils.GetRecordVideoPath();

                AppUtils.MoveFile(recordFullFileName, System.IO.Path.Combine(recordVideoPath, RecorderHelper.StartRecordTime.ToString("微课-yyyyMMddHHmmss") + ".mp4"));
            }
            catch (Exception ex)
            {
                mr.Status  = 99;
                mr.Message = ex.ToString();
                //Log.Write(ex);
            }
            finally
            {
            }

            return(mr);
        }
Пример #7
0
 private void App_OnExit(object sender, ExitEventArgs e)
 {
     RecorderHelper.UnInitializeRecorder();
 }
Пример #8
0
 private void App_OnStartup(object sender, StartupEventArgs e)
 {
     RecorderHelper.InitializeRecorder();
 }
Пример #9
0
        static void Main(string[] args)
        {
            while (true)
            {
                try
                {
                    #region 查找光驱设备
                    Console.Clear();
                    Console.WriteLine("正在查找光驱设备..");
                    List <Recorder> recorderList = RecorderHelper.GetRecorderList();
                    if (recorderList.Count <= 0)
                    {
                        Console.WriteLine("没有可以使用的光驱,请检查.");
                        Console.WriteLine("请连接光驱后,按任意键重试...");
                        Console.ReadKey();
                        continue;
                    }
                    for (int i = 0; i < recorderList.Count; i++)
                    {
                        Recorder tempRecorder = recorderList[i];
                        Console.WriteLine($"发现光驱设备:[{i+1}]  {tempRecorder.RecorderName}");
                        Console.WriteLine($"媒体类型:{tempRecorder.CurMediaTypeName}");
                        Console.WriteLine($"媒体状态:{tempRecorder.CurMediaStateName}");
                        Console.WriteLine("支持刻录:" + (tempRecorder.CanBurn ? "√" : "×"));
                        Console.WriteLine($"可用大小:{FormatFileSize(tempRecorder.FreeDiskSize)}");
                        Console.WriteLine($"总大小:{FormatFileSize(tempRecorder.TotalDiskSize)}");
                    }
                    if (!recorderList.Any(r => r.CanBurn))
                    {
                        Console.WriteLine("没有可以用于刻录的光驱设备,请检查后,按任意键重试.");
                        Console.ReadKey();
                        continue;
                    }
                    #endregion

                    #region  择刻录使用的光驱
                    Recorder recorder;
                    if (recorderList.Count > 1)
                    {
                        Console.WriteLine("发现多个光驱设备,请输入序号选择刻录使用的光驱.");
                        int recorderIndex = -1;
                        while (recorderIndex == -1)
                        {   //tempIndex 1开始
                            int    tempIndex        = -1;
                            string recorderIndexStr = Console.ReadLine();
                            int.TryParse(recorderIndexStr, out tempIndex);
                            if (tempIndex - 1 < 0 || tempIndex > recorderList.Count)
                            {
                                Console.WriteLine("输入序号无效,请重新输入.");
                                continue;
                            }
                            if (!recorderList[tempIndex - 1].CanBurn)
                            {
                                Console.WriteLine("当前设备状态异常,不能进行刻录,请选择其它设备.");
                                continue;
                            }
                            recorderIndex = tempIndex - 1;
                        }
                        recorder = recorderList[recorderIndex];
                    }
                    else
                    {
                        recorder = recorderList[0];
                    }
                    Console.WriteLine($"使用设备[{recorder.RecorderName}  {recorder.CurMediaTypeName}]进行刻录");
                    #endregion

                    #region 添加刻录文件
                    while (true)
                    {
                        Console.WriteLine("添加文件:请输入待刻录文件或文件夹路径. 0完成 1查看已添加文件");
                        string filePath = Console.ReadLine();
                        if (string.IsNullOrEmpty(filePath))
                        {
                            continue;
                        }
                        else if (filePath == "0")
                        {
                            break;
                        }
                        else if (filePath == "1")
                        {
                            ShowBurnMediaListInfo(recorder);
                        }
                        else
                        {
                            try
                            {
                                BurnMedia media = recorder.AddBurnMedia(filePath);
                                Console.WriteLine($"添加成功:{filePath}");
                                Console.WriteLine("文件大小:" + FormatFileSize(media.Size));
                                Console.WriteLine("已添加文件总大小:" + FormatFileSize(recorder.BurnMediaFileSize));
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine($"添加失败:{ex.Message}");
                            }
                        }
                    }
                    #endregion

                    #region 刻录文件

                    if (recorder.BurnMediaList.Count <= 0)
                    {
                        Console.WriteLine($"未添加任何刻录文件.已退出刻录过程.");
                    }
                    else
                    {
                        #region 刻录前确认
                        bool confirmBurn = false;
                        Console.Clear();
                        ShowBurnMediaListInfo(recorder);
                        while (true)
                        {
                            Console.WriteLine();
                            Console.ForegroundColor = ConsoleColor.DarkGreen; //设置颜色.
                            Console.WriteLine($"刻录过程一旦开始,终止可能会造成磁盘损坏.确认要开始刻录(y/n)?");
                            Console.ForegroundColor = colorFore;              //还原颜色.
                            string confirmStr = Console.ReadLine();
                            if (confirmStr.ToLower() == "n")
                            {
                                break;
                            }
                            else if (confirmStr.ToLower() == "y")
                            {
                                confirmBurn = true;
                                break;
                            }
                        }
                        if (!confirmBurn)
                        {
                            Console.WriteLine($"本次刻录过程已退出");
                            continue;
                        }
                        #endregion
                        Console.CursorVisible = false; //隐藏光标
                        ShowBurnProgressChanged(recorder);
                        recorder.Burn();               //刻录
                        Console.WriteLine();
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"异常:{ex.Message}\r\n{ex.StackTrace}");
                }
                Console.WriteLine($"按任意键退出...");
                Console.ReadKey();
            }
        }
Пример #10
0
 private void RecordBtn_OnClick(object sender, RoutedEventArgs e)
 {
     RecorderHelper.StartRecord(this);
 }
Пример #11
0
 public void StopRecording()
 {
     this.Hide();
     RecorderHelper.StopRecording();
 }