我在后台播放音乐。
我可以使用以下代码停止音乐:
Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles audio.Click
My.Computer.Audio.Stop()
End Sub
但我无法重启或恢复它。
那么,可以为单个按钮分配静音开/关(或启动/停止)功能吗?
答案 0 :(得分:0)
您可以使用变量。尝试以下技术:
Dim IsAudioPlaying As Boolean = True
Private Sub PictureBox3_Click(sender As Object, e As EventArgs) Handles audio.Click
If IsAudioPlaying Then
My.Computer.Audio.Stop()
IsAudioPlaying = False
Else
My.Computer.Audio.Play(Nothing)
IsAudioPlaying = True
End If
End Sub