How do multiple audio files play sequentially?

In my C # application, I need to play several audio files ( WAV and MP3 ) one by one. How can i do this?

+3
source share
2 answers

CodeProject has several examples showing how to play audio. Once you get stuck in the fact that playing multiple files one after another should be easy.

, winmm.dll . 3

+2

NAudio WAV

 private List<string> wavlist = new List<string>();
 wavlist.Add("c:\\1.wav");
 wavlist.Add("c:\\2.wav");
 foreach(string file  in wavlist)
 {
      AudioFileReader audio = new AudioFileReader(file);
      audio.Volume = 1;
      IWavePlayer player = new WaveOut(WaveCallbackInfo.FunctionCallback());
      player.Init(audio);
      player.Play();
      System.Threading.Thread.Sleep(audio.TotalTime);
      player.Stop();
      player.Dispose();
      audio.Dispose();
      player = null;
      audio = null;
  }
+1

Source: https://habr.com/ru/post/1710521/


All Articles