播放使用C#MP3文件 [英] Playing MP3 file using C#
本文介绍了播放使用C#MP3文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在寻找播放MP3文件,没有任何第3方发挥它的方式(媒体播放器等),有什么办法这样做呢?
谢谢你。
I'm looking for a way for playing an MP3 file without any 3rd side playing it(Media Player, etc) Is there any way for doing it? Thank you.
推荐答案
我已经写了一个开源库 n音讯了能做到这一点:
I have written an open source library called NAudio that can do this:
private IWavePlayer waveOut;
private Mp3FileReader mp3FileReader;
private void PlayMp3()
{
this.waveOut = new WaveOut(); // or new WaveOutEvent() if you are not using WinForms/WPF
this.mp3FileReader = new Mp3FileReader("myfile.mp3");
this.waveOut.Init(mp3FileReader);
this.waveOut.Play();
this.waveOut.PlaybackStopped += OnPlaybackStopped;
}
private void OnPlaybackStopped(object sender, EventArgs e)
{
this.waveOut.Dispose();
this.mp3FileReader.Dispose();
}
这篇关于播放使用C#MP3文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文