Search code examples
c#mp3naudio

C# Naudio Mp3 Play Button


I'm trying over a few days and can't make a simple Play button over C# using NAudio. It works, but when I hit the button the sound doesn't come out. Tried to put the mp3 file on the project folder and nothing happens.

public partial class MainForm : Form
{
    public MainForm()
    {

        InitializeComponent();
    }
        private WaveOut waveOut;
        private Mp3FileReader reader;



    private void Button1(object sender, EventArgs e)
    {
   reader = new Mp3FileReader("c:\\tng\\tng.mp3");
   waveOut = new WaveOut(); 
   waveOut.Init(reader); 
   waveOut.Play();
    }

}

}


Solution

  • (I didn't really run just guess) Try this?

       reader = new Mp3FileReader("c:\\tng\\tng.mp3");
       waveOut = new WaveOut(); 
       waveOut.Init(reader); 
       waveOut.Play();
       //add this line
       Thread.Sleep(600000);