Esempio n. 1
0
 private void Start()
 {
     try
     {
         Capturer                = new WasapiLoopbackCapture();
         TargetFormat            = new WaveFormat(16000, 8, 1);
         SendTimer               = Stopwatch.StartNew();
         Capturer.DataAvailable += (aud, args) =>
         {
             try
             {
                 if (args.BytesRecorded > 0)
                 {
                     lock (TempBuffer)
                     {
                         if (!SendTimer.IsRunning)
                         {
                             SendTimer.Restart();
                         }
                         TempBuffer.AddRange(args.Buffer.Take(args.BytesRecorded));
                         if (TempBuffer.Count > 200000)
                         {
                             SendTimer.Reset();
                             SendTempBuffer();
                         }
                         else if (SendTimer.Elapsed.TotalMilliseconds > 1000)
                         {
                             SendTimer.Reset();
                             SendTempBuffer();
                         }
                     }
                 }
             }
             catch
             {
             }
         };
         Capturer.StartRecording();
     }
     catch
     {
     }
 }
Esempio n. 2
0
 private void Stop()
 {
     Capturer?.StopRecording();
     SendTimer?.Reset();
 }