Jouer un mp3 en boucle

stepaustral Messages postés 54 Date d'inscription dimanche 5 janvier 2003 Statut Membre Dernière intervention 29 juillet 2012 - 2 juin 2006 à 16:10
PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 - 3 juin 2006 à 20:34
Bonjour,

Tous est dans le titre.
Voici le code que j'ai mis dans une form il reste a insérer le code pour lire en boucle le mp3, si quelqu'un a une idée.

Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim ret As Long, mp3file As String, mp3shortfile As String
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
ret = mciSendString("Stop sonido", 0, 0, 0)
ret = mciSendString("Close sonido", 0, 0, 0)
End Sub



Private Sub Form_Load()
mp3file = "C:\Program Files\Sudokumania\son.mp3"
mp3shortfile = Space(Len(mp3file))
ret = GetShortPathName(mp3file, mp3shortfile, Len(mp3file))
mp3shortfile = Left(mp3shortfile, ret)
ret = mciSendString("OPEN " & mp3shortfile & " Alias Sonido", 0, 0, 0) 'ouvre
ret = mciSendString("Play sonido", 0, 0, 0) 'Joue
End Sub

2 réponses

stepaustral Messages postés 54 Date d'inscription dimanche 5 janvier 2003 Statut Membre Dernière intervention 29 juillet 2012
2 juin 2006 à 21:16
Quelqu'un aurait il un moyen de faire jouer un mp3 en boucle au chargement d'une form.Tous vos conseils me serons utile même si c'est un autre code, du moment que ça fonctionne car je n'ai pas trouvé mon bonheur dans les sources ni dans le forum.
Merci
0
PCPT Messages postés 13272 Date d'inscription lundi 13 décembre 2004 Statut Membre Dernière intervention 3 février 2018 47
3 juin 2006 à 20:34
salut,

beh t'as pas du bien chercher...

une Form, un Timer, et ma classe (36041 dispo ici)

Option Explicit 
Private AfSound     As New AfCls_Sound 
Dim sMP3            As String 
'
'
Private Sub Form_Load() 
    Me.Width  = 9615 
    Me.Height = 405 
'   init fichier à lire
    sMP3 = App.Path & "\datas\cette_petite_chose.mp3" 
    AfSound.PlayMCI (sMP3) 
    '
    Timer1.Enabled = True 
    Timer1.Interval = 200 
End Sub 
'
'
Private Sub Form_Unload(Cancel As Integer) 
    Timer1.Enabled = False 
    Set AfSound = Nothing 
End Sub 
'
'
Private Sub Timer1_Timer() 
    Dim lPerc As Long 
    lPerc = AfSound.GetPercentMCI 
    '
    If lPerc = 100 Then 
'       on joue en boucle + affichage (pour verif)
        Me.Caption = sMP3 & "  (100 %)" 
        AfSound.PlayMCI (sMP3) 
    ElseIf lPerc <> -1 Then 
'       çà c'est juste pour vérifier
        Me.Caption = sMP3 & "  (" & CStr(lPerc) & " %)" 
    End If 
End Sub 

<small> Coloration
syntaxique automatique [AFCK]</small>
       

si tu préfères les usercontrol, regarde la source de plus près

n'hésite pas à y laisser un commentaire (noté?)
++
PCPT   [AFCK]
0
Rejoignez-nous