[C#] 纯文本查看 复制代码
using System;
using System.Text;
using NAudio.Wave;
using NAudio.CoreAudioApi;
using System.Threading;
using System.IO;
namespace HelloCsharp
{
class Program
{
static void Main()
{
using (var ms = File.OpenRead(@"test.mp3"))
using (var rdr = new Mp3FileReader(ms))
using (var wavStream = WaveFormatConversionStream.CreatePcmStream(rdr))
using (var baStream = new BlockAlignReductionStream(wavStream))
using (var waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()))
{
waveOut.Init(baStream);
waveOut.Play();
while (waveOut.PlaybackState == PlaybackState.Playing)
{
Thread.Sleep(100);
}
}
}
}