Please show me the code to -- play songs, through Windows Media Player 9, while my program's exe (written in VB 6) runs.
What I have tried is,
In a form I have taken
1) 'Windows Media Player' control ('wmp.dll') from 'Project' Menu --> 'Components'.
2) 'FileListBox' control, which contains file names of songs as a list (By setting 'path' & 'pattern' properties.
The code of the form is as below.
But it plays only first song and none of the others.
If I put a breakpoint at a line shown below, it starts playing next song and plays it till the execution is paused due to breakpoint, as soon as I start paused execution by pressing 'F5', it stops playing.
Please help me to solve this problem. Thanks in Advance.
------------------------------------------------------------------------------
Dim FlNms() As String 'name of the song file.
Dim FlCnt As Double 'to count total number of files.
Dim CrntFlNm As Double 'the number of the file to play next.
Dim PList As WMPPlaylistCtrl
------------------------------------------------------------------------------
Public Sub Form_Load()
Dim i As Integer
fl.Path = App.Path & "\Data"
fl.Pattern = "*.mp3;*.wav"
FlCnt = fl.ListCount
ReDim FlNms(FlCnt)
For i = 0 To FlCnt - 1
FlNms(i) = fl.List(i)
Next
CrntFlNm = 0
Me.Left = 0
Me.Top = 0
Call PlaySong
End Sub
------------------------------------------------------------------------------
Private Sub MP1_PlayStateChange(ByVal NewState As Long)
If NewState = 8 Then
Call PlaySong
End If
End Sub
------------------------------------------------------------------------------
Private Sub PlaySong()
MP1.settings.autoStart = True
MP1.Controls.Play
MP1.URL = App.Path & "\Data" & FlNms(CrntFlNm)
CrntFlNm = CrntFlNm + 1 '''' Breakpoint
If CrntFlNm = FlCnt Then
CrntFlNm = 0
End If
End Sub
------------------------------------------------------------------------------
ASKED:
Aug 10 2008 10:45 AM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _