Example #1
0
 public void StopRecording()
 {
     Logging.Instance.WriteLine("Stoping recording...");
     try
     {
         hasRecording = true;
         if (m_Recorder != null)
             try
             {
                 Logging.Instance.WriteLine("Recorder is not null");
                 m_Recorder.Dispose();
             }
             finally
             {
                 m_Recorder = null;
             }
         if (m_Writer != null)
             try
             {
                 Logging.Instance.WriteLine("Writer is not null");
                 m_Writer.Close();
             }
             finally
             {
                 m_Writer = null;
             }
     }
     catch (Exception ex)
     {
         Logging.Instance.WriteLine(ex.StackTrace);
     }
     Logging.Instance.WriteLine("Stopped Recording!");
 }
Example #2
0
 public void StartRecording()
 {
     Logging.Instance.WriteLine("Starting recording...");
     StopRecording();
     Logging.Instance.WriteLine("StartRecording has stoped recording");
     try
     {
         WaveFormat fmt = new WaveFormat(44100, 16, 2);
         Logging.Instance.WriteLine("Created fmt");
         Mp3WriterConfig config = new Mp3WriterConfig(fmt);
         Logging.Instance.WriteLine("created config");
         if (filePath == null)
         {
             Logging.Instance.WriteLine("File Path is null");
             filePath = GetFilePath();
             Logging.Instance.WriteLine("File Path:" + filePath);
         }
         //DoRecord = false;
         currentFile = new FileStream(filePath, FileMode.Append);
         m_Writer = new Mp3Writer(currentFile, config);
         Logging.Instance.WriteLine("writer intialized");
         m_Recorder = new WaveInRecorder(-1, fmt, 16384, 3, new BufferDoneEventHandler(DataArrived));
         Logging.Instance.WriteLine("recorder initialized");
     }
     catch (Exception ex)
     {
         Logging.Instance.WriteLine(ex.StackTrace);
         StopRecording();
         throw ex;
     }
     Logging.Instance.WriteLine("leaving start recording");
 }