1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| Option Explicit
Dim LongSupport As Long
Dim morceau As Integer
Dim essai As Integer
Dim titre1 As Variant
Dim titre2 As Variant
Dim titre3 As Variant
Dim titre4 As Variant
Dim titre1b As Variant
Dim titre2b As Variant
Dim titre3b As Variant
Dim titre4b As Variant
Private Sub Form_Load()
Open "c:\fichier.txt" For Input As #2
Input #2, titre1
Input #2, titre2
Input #2, titre3
Input #2, titre4
Close #2
titre1b = "K:\player\zik\" & titre1 & ".mp3"
titre2b = "K:\player\zik\" & titre2 & ".mp3"
titre3b = "K:\player\zik\" & titre3 & ".mp3"
titre4b = "K:\player\zik\" & titre4 & ".mp3"
MMControl1.FileName = titre1b '********** à adapter ********
morceau = 1
Label1.Caption = titre1
lecture
End Sub
Private Sub MMControl1_Done(NotifyCode As Integer)
If MMControl1.Position >= LongSupport - 2 Then
'detection de la fin de lecture du fichier pour le relancer en boucle
Label1.Caption = 1
MMControl1.Command = "close"
Select Case morceau
Case 1
MMControl1.FileName = titre2b
Label1.Caption = titre2
morceau = 2
Case 2
MMControl1.FileName = titre3b
Label1.Caption = titre3
morceau = 3
Case 3
MMControl1.FileName = titre4b
Label1.Caption = titre4
morceau = 4
Case 4
End
End Select
lecture
End If
End Sub
Private Sub lecture()
MMControl1.DeviceType = "mpegvideo" 'pour mp3 sa fonctinne aussi
On Error Resume Next
MMControl1.Wait = True
MMControl1.Command = "Open"
DoEvents
If MMControl1.Length = 0 Or Err.Number <> 0 Then
On Error GoTo 0
MsgBox "impossible d'ouvrire le fichier", vbInformation
Unload Me
Exit Sub
End If
LongSupport = MMControl1.Length 'longueur du fichier
MMControl1.Notify = True 'pour declancher Private Sub MMControl1_Done
MMControl1.Command = "Play"
End Sub |
Partager