【实例简介】
开启前输入对方IP点击录音然后发送即可
【实例截图】
【核心代码】
using NAudio.CoreAudioApi;
using NAudio.Wave;
using Netframe.Core;
using Netframe.Event;
using Netframe;
using Netframe.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Input;
using System.Threading;
namespace 语音
{
public partial class Form1 : Form
{
// MsgTranslator tran = null;
public Form1()
{
InitializeComponent();
LoadWasapiDevicesCombo();
CheckForIllegalCrossThreadCalls = false;
//Config cfg = SeiClient.GetDefaultConfig();
//cfg.Port = 7777;
//UDPThread udp = new UDPThread(cfg);
//tran = new MsgTranslator(udp, cfg);
//tran.MessageReceived = tran_MessageReceived;
//tran.Debuged = new EventHandler(tran_Debuged);
}
//------------------录音相关-----------------------------
private IWaveIn waveIn;
private WaveFileWriter writer;
private IWavePlayer wavePlayer;
private WaveStream reader;
//麦克风
private void LoadWasapiDevicesCombo()
{
var deviceEnum = new MMDeviceEnumerator();
var devices = deviceEnum.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active).ToList();
comboBox1.DataSource = devices;