我想在表单加载时使背景音乐自动播放。有人能帮我吗?我的代码是:
My.Computer.Audio.Play(My.Resources.christs, AudioPlayMode.BackgroundLoop)
答案 0 :(得分:4)
这是针对 on Load 事件
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