/// <summary> /// 关闭麦克风,释放资源 /// </summary> public void CloseMircoPhone() { if (microphoneCapturer != null) { microphoneCapturer.Stop(); microphoneCapturer.Dispose(); microphoneCapturer = null; } if (videoFileMaker != null) { videoFileMaker.Close(true); videoFileMaker.Dispose(); videoFileMaker = null; } }
//Part1 语音通信 private void button1_Click_1(object sender, EventArgs e) { if (button1.Text == "语音通话") { //远端socket配置 ipeRemote1 = new IPEndPoint(IPAddress.Parse(label1.Text.ToString()), 8500); audioPlayer = PlayerFactory.CreateAudioPlayer(0, 16000, 1, 16, 2); microphoneCapturer = CapturerFactory.CreateMicrophoneCapturer(0); microphoneCapturer.AudioCaptured += new ESBasic.CbGeneric <byte[]>(microphoneCapturer_AudioCaptured); Listen_sound(); microphoneCapturer.Start(); button1.Text = "停止语音通话"; } else { microphoneCapturer.Stop(); ListenThread_sound.Suspend(); button1.Text = "语音通话"; } }