C# NAudio 播放多个MP3文件

C# 使用 NAudio 来播放多个MP3文件。上代码
1.引入NAudio:using NAudio.Wave;
2.定义变量:
private WaveOutEvent outputDevice;//设备 private AudioFileReader audioFile;//文件
3.方法:
public void PlayMultipleFileByNAudio(string[] urls) { outputDevice = new WaveOutEvent(); for (int i=0;i<urls.Length;i++) { audioFile = new AudioFileReader(urls[i]); outputDevice.Init(audioFile); outputDevice.Play(); while (outputDevice.PlaybackState == PlaybackState.Playing) { Thread.Sleep(1000); } } }

posted @ 2024-01-22 16:33  瘦腿先生Stephen  阅读(331)  评论(0编辑  收藏  举报