예제 #1
0
        private void StopRecivePic()
        {
            if (m_bRecivingPic)
            {
                if (null != doImages)
                {
                    doImages.Done = true;
                    doImages = null;
                }

                m_bRecivingPic = false;

                pictureBox1.Image = Image.FromFile(Directory.GetCurrentDirectory() + @"\wall-e.jpg");

                // 关闭音频线程
                if (null != m_doRemoteVoice)
                {
                    m_doRemoteVoice.Done = true;
                    m_doRemoteVoice = null;
                }
                if (null != m_objVP)
                {
                    m_objVP.Stop();
                    m_objVP = null;
                }
                if (null != m_objBuf)
                {
                    m_objBuf.Clear();
                    m_objBuf = null;
                }
            } // end of if
        }
예제 #2
0
        private void StartRecivePic()
        {
            if (!m_bRecivingPic)
            {
                try
                {
                    // 视频
                    m_Count = 0;
                    doImages = new DoImages(this, IP, PORT);
                    doImages.StopReciveImage += new StopReciveImageEventHandler(StopRecivePic);
                    doImages.ImageReady += new ImageReadyEventHandler(doImages_ImageReady);
                    ThreadStart o = new ThreadStart(doImages.ThreadProc);
                    Thread thread = new Thread(o);
                    thread.Name = "Imaging";
                    thread.Start();

                    // 音频
                    m_doRemoteVoice = new DoVoice(this, IP, m_nSoundPort);
                    m_doRemoteVoice.StopReciveVoice += new StopReciveImageEventHandler(StopRecivePic);
                    m_doRemoteVoice.VoiceReady += new VoiceReadyEventHandler(m_doRemoteVoice_VoiceReady);
                    ThreadStart s = new ThreadStart(m_doRemoteVoice.ThreadProc);
                    Thread t = new Thread(s);
                    t.IsBackground = true;
                    t.Name = "RemoteVoicing";
                    //m_wav = new WavFile(@"C:\test.wav");
                    //m_wav.BeginCreateFile();

                    m_objBuf = new CircularBuffer(WavFile.GetDefalultWavFormat().AverageBytesPerSecond / 8);
                    m_objVP = new VoicePlayer(this.Handle, WavFile.GetDefalultWavFormat());
                    m_objVP.ReadyForNewData += new ReadyForNewDataEventHandler(m_objVP_ReadyForNewData);
                    m_objVP.Start();
                    m_nNextWritePos = m_objVP.nNotifySize * 2;
                    t.Start();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    return;
                }

                m_bRecivingPic = true;
            } // end of if
        }