2013-11-28 98 views
0

我想在表單加載時使背景音樂自動播放。有人能幫我嗎?我的代碼是:VB.Net當自動播放BG音樂

My.Computer.Audio.Play(My.Resources.christs, AudioPlayMode.BackgroundLoop) 
+0

請描述你的問題。什麼不工作? – Inisheer

+0

它正在工作,我只想知道如何使表單加載時自動播放背景音樂。 – EysAce

+0

嘗試表單加載事件(Form1_Load)。當表單關閉時,您還需要能夠阻止它。 – NoChance

回答

4

這是上加載事件

Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
My.Computer.Audio.Play(My.Resources.christs, AudioPlayMode.BackgroundLoop) 
End Sub 

和音頻停止,如果形式是關閉

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing 
My.Computer.Audio.Stop(My.Resources.christs, AudioPlayMode.BackgroundLoop) 
End Sub