2016-06-15 119 views
1

我想了幾天,不能使用NAudio在C#上做一個簡單的播放按鈕。它可以工作,但是當我按下按鈕時,聲音不會出來。試圖把mp3文件放在項目文件夾中,沒有任何反應。C#Naudio Mp3播放按鈕

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(); 
    } 

} 

}

+0

請檢查這個[URL](http://stackoverflow.com/help)這將是提升內容質量達到 –

回答

0

(我真的不跑只是猜測)試試這個?

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

感謝@宇陽建有用 – hamm3r