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); } } }
本文来自博客园,作者:瘦腿先生Stephen,转载请注明原文链接:https://www.cnblogs.com/Stephen-leg/p/17980335