Voiçi le code que j'ai utilisé pour lire un fichier son dans mon application.
MMControl1.Notify = False
MMControl1.Wait = True
MMControl1.Shareable = False
MMControl1.DeviceType = "waveAudio"
'MMControl1.FileName = "C:\POCC\Bus6.WAV"
MMControl1.FileName = "C:\POCC\OK2.WAV"
MMControl1.Command = "open"
MMControl1.Command = "play"
Le fichier c'est OK2. Mais je voudrais que cette lecture se repète chaque fois qu'il est à la fin;et aussi longtemps qu'on a pas encore quitté l'application. comment faire?
Private Sub Boucle()
MMControl1.Notify = False
MMControl1.Wait = True
MMControl1.Shareable = False
MMControl1.DeviceType = "waveAudio"
'MMControl1.FileName = "C:\POCC\Bus6.WAV"
MMControl1.FileName = "C:\POCC\OK2.WAV"
MMControl1.Command = "open"
MMControl1.Command = "play"
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'1000 mili 1sec * 60 1 m
Dim isec As Integer
isec += 1
If isec = 60 Then
Boucle()
isec = 0
End If
End Sub
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
A mettre le fichier wav dans le dossier Debug de l'application
@+
Le Pivert
oui tu as raison avec cette commande il joue en boucle
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