C# 使用NAudio获取声卡名称及播放Mp3
命名空间:
using NAudio; using NAudio.Wave;
获取声卡名称
for (int deviceid = 0; deviceid < WaveOut.DeviceCount; deviceid++) { var capabilities = WaveOut.GetCapabilities(deviceid); //capabilities.ProductName; //ProductName即是声卡名称 }
播放MP3
WaveOut waveOutDevice = new WaveOut(); AudioFileReader audioFileReader = new AudioFileReader("D:\\FDownload\\Epic.mp3"); waveOutDevice.DeviceNumber = 2; waveOutDevice.Init(audioFileReader); waveOutDevice.Play();