i use mediaplayer to play .wav files but i am listing more then one files in my listbox so what i like to do is when one file is finish playing it will goto the next file in listbox and play that file.
Printable View
i use mediaplayer to play .wav files but i am listing more then one files in my listbox so what i like to do is when one file is finish playing it will goto the next file in listbox and play that file.
Hi! amitkhatri, I pressume that all your wav file is locate at a fixed path as "C:\Wav\"
Code:Option Explicit
Private Idx As Long
Private Sub Command1_Click()
Idx = 0
PLAY_WAV_LIST
End Sub
Private Sub Form_Load()
LOAD_WAV_LIST
End Sub
Private Sub LOAD_WAV_LIST()
Dim f As String
f = Dir("C:\wav\")
Do While f <> ""
List1.AddItem f
f = Dir()
DoEvents
Loop
End Sub
Private Sub PLAY_WAV_LIST()
MediaPlayer1.FileName = "C:\Wav\" & List1.List(Idx)
MediaPlayer1.Play
End Sub
Private Sub MediaPlayer1_EndOfStream(ByVal Result As Long)
If Idx <> List1.ListCount - 1 Then
Idx = Idx + 1
PLAY_WAV_LIST
End If
End Sub