i have a list of items in a listbox and i when i double click the listbox it plays that song... but what i need to do is that when the song is finished playing(ended), it will start the next song listed on the listbox.
OK, here is the full source code from that zip file. You will need to add the controls however.
Code:
Dim lstindex As Long
Dim PreviousIndex As Integer
Dim DefaultPlaylistDirectory As String
Const TitlebarCaption = "Media Player"
Private Sub Form_Load()
On Error Resume Next
'
' Change below to your default folder where you have your music files
'
DefaultPlaylistDirectory = "M:\All of My Music\Every_MP3_I_Have"
MediaPlayer1.ShowCaptioning = True
MediaPlayer1.ShowStatusBar = True
lblBigTitle.Caption = ""
List1.Clear
List2.Clear
'
' Default Playlist
'
File1.Path = DefaultPlaylistDirectory
For i = 0 To File1.ListCount - 1
List1.List(List1.ListCount) = Left(File1.List(i), Len(File1.List(i)) - 4)
List2.List(List2.ListCount) = File1.Path & "\" & File1.List(i)
Next i
Caption = TitlebarCaption & " - [" & File1.Path & "]"
lblTotalSelections = "Total Selections: " & List1.ListCount
MediaPlayer1.ClickToPlay = True '.AutoStart = True
End Sub
Private Sub Form_Resize()
Dim MeWidth As Long
Dim MeHeight As Long
On Error Resume Next
If Me.Height < 6060 Then Me.Height = 6060
If Me.Width < 8625 Then Me.Width = 8625
MeWidth = Me.Width
MeHeight = Me.Height
Select Case Me.WindowState
Case vbNormal
List1.Height = Me.Height - 1125
Me.Height = List1.Height + 1125
MeWidth = Me.Width
MeHeight = Me.Height
Case vbMinimized
'
Case vbMaximized
List1.Height = Me.Height - 1125
MeWidth = Me.Width
MeHeight = Me.Height
Me.WindowState = vbNormal
Me.Move 0, 0, MeWidth, MeHeight
End Select
Picture3.Height = Me.Height - 750
Picture4.Height = Me.Height - 750
MediaPlayer1.Height = Picture4.Height - 720
Picture4.Width = Me.Width - 4455
MediaPlayer1.Width = Picture4.Width - 60
Picture1.Width = Picture4.Width - 60
lblBigTitle.Width = Picture1.Width - 15
End Sub
Private Sub List1_DblClick()
On Error Resume Next
List1.Selected(lstindex) = False
MediaPlayer1.Stop
MediaPlayer1.FileName = List2.List(List1.ListIndex)
List1.Selected(lstindex) = False
lblBigTitle.Caption = List1.List(List1.ListIndex)
lstindex = List1.ListIndex
List1.Selected(lstindex) = True
lblNofN.Caption = "Playing " & List1.ListIndex + 1 & " of " & List1.ListCount
End Sub
Private Sub MediaPlayer1_Click(Button As Integer, ShiftState As Integer, x As Single, y As Single)
' Stop
End Sub
Private Sub MediaPlayer1_EndOfStream(ByVal Result As Long)
On Error Resume Next
If miPlaySelectedContinue.Checked = True Then
MediaPlayer1.FileName = List2.List(List1.ListIndex)
Else
If Not lstindex = List1.ListCount - 1 Then
lstindex = lstindex + 1
MediaPlayer1.FileName = List2.List(lstindex)
lblBigTitle.Caption = List1.List(lstindex)
List1.ListIndex = lstindex
List1.Selected(lstindex - 1) = False
List1.Selected(lstindex) = True
lblNofN.Caption = "Playing " & List1.ListIndex + 1 & " of " & List1.ListCount
Else
If miPlayAllContinue.Checked = True Then
List1.ListIndex = 0
List1.Selected(lstindex) = False
MediaPlayer1.FileName = List2.List(List1.ListIndex)
List1.Selected(lstindex) = False
lblBigTitle.Caption = List1.List(List1.ListIndex)
lstindex = List1.ListIndex
List1.Selected(lstindex) = True
lblNofN.Caption = "Playing " & List1.ListIndex + 1 & " of " & List1.ListCount
End If
End If
End If
End Sub
Private Sub FileOpen()
On Error GoTo ErrHandler
Dim vFiles As Variant
Dim lFile As Long
'
' Use Ctrl-A to Select All entries from the dialogbox
'
With CommonDialog1
.FileName = "" 'Clear the filename
.CancelError = True
.DialogTitle = "Select File(s)..."
.Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNHideReadOnly 'Flags, allows Multi select, Explorer style and hide the Read only tag
.Filter = "All files (*.*)|*.*"
.MaxFileSize = 32767 ' Allows a buffer large enough to hold the total number of file names selected
.InitDir = DefaultPlaylistDirectory
.ShowOpen
vFiles = Split(.FileName, Chr(0)) 'Splits the filename up in segments
'
' If there is only 1 file then do this
'
If UBound(vFiles) = 0 Then
List1.Clear
List2.Clear
List2.AddItem .FileName
List1.AddItem .FileTitle
k = InStrRev(.FileName, "\")
Caption = TitlebarCaption & " - [" & Left(.FileName, k - 1) & "]"
DefaultPlaylistDirectory = Left(.FileName, k - 1)
lblTotalSelections = "Total Selections: " & List1.ListCount
Else
List1.Clear
List2.Clear
'
' More than 1 file then do this until there are no more files
'
For lFile = 1 To UBound(vFiles)
List2.AddItem vFiles(0) + "\" & vFiles(lFile)
List1.AddItem vFiles(lFile)
Next
k = InStrRev(.FileName, "\")
Caption = TitlebarCaption & " - [" & Left(.FileName, k - 1) & "]"
DefaultPlaylistDirectory = Left(.FileName, k - 1)
lblTotalSelections = "Total Selections: " & List1.ListCount
End If
End With
Exit Sub
ErrHandler:
If Err <> cdlCancel Then
MsgBox Err.Description
End If
End Sub
Private Sub miOpen_Click()
FileOpen
End Sub
Private Sub miPlayAllContinue_Click()
If miPlayContinue.Checked = True Then
miPlayContinue.Checked = False
Else
miPlayContinue.Checked = True
End If
End Sub
Private Sub miPlaySelectedContinue_Click()
If miPlaySelectedContinue.Checked = True Then
miPlaySelectedContinue.Checked = False
Else
miPlaySelectedContinue.Checked = True
End If
End Sub
What does that mean? Are you saying that when you try to open the .vbp project nothing happens, nothing at all? Something has to take place; I mean I dont believe that it is total silence.
Well for pete sakes can you not give us a little more info? What do you expect us to do when all you say is i get 2 errors and it gives me an error. We need details. I don't have any problem with it and koolsid didn't have any problems with it so why should you have problems.
Well, that is a totally different problem. So the problem is not with the project but rather with your system not being able to load the OCX. OK, I will send another ZIP file and let's see what that one does.
i will just work on my next project and leave this one for later... i'm trying to be first in school to finish it... but that doesnt matter our teacher will help us when we come to the time we need replay and play a list.
Don't worry about that; just go ahead and allow the project to load up and then resave it and that message won't come up again. I think it was just left in the .vbp file after I renamed Form1 to MediaPlayerForm.frm