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();

 

posted @ 2016-03-10 15:31  逍遥子k  阅读(3252)  评论(2编辑  收藏  举报