2016-07-16 30 views
-2

我試圖讓一個.wav音樂文件在程序啓動時啓動。 不,我不想在用戶點擊按鈕時播放音樂,我試圖在程序啓動時使音樂自行啓動。當我的程序以c#啓動時,如何在背景中創建音樂?

我需要它爲我的C#程序。

+0

您正在使用的WinForms? –

+0

我正在使用Microsoft Visual Studio! – ZombieKnifer223

+1

相關:http://stackoverflow.com/questions/3502311/how-to-play-a-sound-in-c-net在你的「主」方法中啓動它。 – 2016-07-16 05:36:26

回答

0

使用聲音播放,並調用它的主要方法:

private static void Main(string[] args) 
{ 
    System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:\test.wav"); 
    player.Play(); 

    // do something else.... 
}