Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'Arrete la lecture du son My.Computer.Audio.Stop() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click My.Computer.Audio.Play(Application.StartupPath & "\fichier.wav", AudioPlayMode.Background) 'joue en arrière plan End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click My.Computer.Audio.Play(Application.StartupPath & "\fichier.wav", AudioPlayMode.WaitToComplete) 'joue complétement, ne s'arrête qu'à la fin du morceau End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click My.Computer.Audio.Play(Application.StartupPath & "\fichier.wav", AudioPlayMode.BackgroundLoop) 'joue en boucle End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load My.Computer.Audio.Play(Application.StartupPath & "\monfichier.wav", AudioPlayMode.BackgroundLoop) 'joue en boucle End Sub 'pour arrêter à la fermeture Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing 'Arrete la lecture du son My.Computer.Audio.Stop() End Sub
Option Strict Off Option Explicit On Module Module1 Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer Public strFileToPlay As String Public bPlaying As Boolean Public Sub Play() If strFileToPlay <> "" Then mciSendString("play " & strFileToPlay, CStr(0), 0, 0) bPlaying = True End If End Sub Public Sub Open() If strFileToPlay <> "" Then mciSendString("open " & strFileToPlay & " type MPEGVideo", CStr(0), 0, 0) End If End Sub Public Sub Pause() If bPlaying Then mciSendString("pause " & strFileToPlay, CStr(0), 0, 0) bPlaying = False End If End Sub End Module
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Call Pause() strFileToPlay = "Chemin du fichier.mp3" strFileToPlay = """" & strFileToPlay & """" Call Open() Call Play() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Call Pause() End Sub