예제 #1
0
        /// <summary>
        /// Start recording, default recording chunck is 1 second
        /// </summary>
        public void StartRecording()
        {
            SoundConnectionSettings settings = new SoundConnectionSettings();

            try
            {
                using (SoundDevice device = SoundDevice.Create(settings))
                {
                    string path = Directory.GetCurrentDirectory();

                    device.StartRecording($"{path}/{FileName}");
                    IsRecording = true;
                    _recording  = true;
                    new Thread(() =>
                    {
                        try
                        {
                            while (_recording)
                            {
                                Thread.Sleep(1);
                            }

                            device.StopRecording();
                            IsRecording = false;
                        }
                        catch
                        {
                            _recording  = false;
                            IsRecording = false;
                        }
                    }).Start();
                }
            }
            catch
            {
                IsRecording = false;
            }
        }