|
-
Aug 5th, 2006, 01:05 PM
#1
Thread Starter
Lively Member
[2005] Need help with the openfiledialog and listview in my mp3 player
Right now i'm working on a mp3 player so to be full media player but I need help with the listview. I can open the music files i select and they appear in the listview and they play using MCI. My problem is I only want it split to show only the song in the listview not the directory that it came from. Here's my code for the openfiledialog:
VB Code:
Dim theList As Collection = New Collection()
Dim x As Integer = Nothing
OFD.Title = "Select music file"
OFD.Multiselect = True
OFD.Filter = "MP3 files (*.m3u, *.mp3, *.wav, *.wma, *.cda)|*.m3u;*.mp3;*.wav;*.wma;*.cda|Playlist (*.m3u)|*.m3u|MP3 files (*.mp3)|*.mp3|WAV files (*.wav)|*.wav|WMA files (*.wma)|*.wma|CDA files (*.cda)|*.cda|All files (*.*)|*.*"
If (OFD.ShowDialog() = Windows.Forms.DialogResult.OK) Then
lstSongs.Items.Clear()
For Each filename As String In OFD.FileNames
If filename.EndsWith(".mp3") Then
lstSongs.Visible = True
lblList.Text = "Hide List"
Dim ttext As String
ttext = Trim(filename)
'If lstSongs.Items.Contains(ttext) = True Then
lstSongs.Items.Add(ttext)
ElseIf filename.EndsWith(".wma") Then
lstSongs.Visible = True
lblList.Text = "Hide List"
Dim ttext As String
ttext = Trim(filename)
'If lstSongs.Items.Contains(ttext) = True Then
lstSongs.Items.Add(ttext)
ElseIf filename.EndsWith(".wav") Then
lstSongs.Visible = True
lblList.Text = "Hide List"
Dim ttext As String
ttext = Trim(filename)
'If lstSongs.Items.Contains(ttext) = True Then
lstSongs.Items.Add(ttext)
ElseIf filename.EndsWith(".cda") Then
lstSongs.Visible = True
lblList.Text = "Hide List"
Dim ttext As String
ttext = Trim(filename)
'If lstSongs.Items.Contains(ttext) = True Then
lstSongs.Items.Add(ttext)
ElseIf OFD.FileName.EndsWith(".m3u") Then
lstSongs.Items.Clear()
theList = Vmp3.openPlaylist(OFD.FileName)
For x = 0 To theList.Count - 1
lstSongs.Items.Add(theList.Item(x + 1))
Next
'lstSongs.Items.Add(OFD.FileName)
End If
Next
End If
-
Aug 5th, 2006, 02:40 PM
#2
Re: [2005] Need help with the openfiledialog and listview in my mp3 player
Hey!
Sorry but I for one doesnt understand the question
-
Aug 5th, 2006, 03:20 PM
#3
Addicted Member
-
Aug 5th, 2006, 03:23 PM
#4
Thread Starter
Lively Member
Re: [2005] Need help with the openfiledialog and listview in my mp3 player
ok for example I open up a .mp3 file to play and it shows up in the listview as c:\Music\random song\anysong.mp3 but I only want the anysong part to show up not the directory of it I need to split it I tried substring and indexof but didn't work
-
Aug 5th, 2006, 03:25 PM
#5
Thread Starter
Lively Member
Re: [2005] Need help with the openfiledialog and listview in my mp3 player
also if my question still isn't makeing any sense I can get a screenshot and maybe explain it better that way because I need help with this
-
Aug 5th, 2006, 04:49 PM
#6
Re: [2005] Need help with the openfiledialog and listview in my mp3 player
VB Code:
Dim f As String = "c:\Music\random song\anysong.mp3"
MsgBox(f.Substring(f.LastIndexOf("\") + 1, f.Length - (f.LastIndexOf("\") + 5)))
Like this?
-
Aug 5th, 2006, 08:06 PM
#7
Thread Starter
Lively Member
Re: [2005] Need help with the openfiledialog and listview in my mp3 player
well I finally got it working thanks Atheist your code put me on the right track this is how I fixed it
VB Code:
If (OFD.ShowDialog() = Windows.Forms.DialogResult.OK) Then
lstSongs.Items.Clear()
For Each filename As String In OFD.FileNames
If filename.EndsWith(".mp3") Then
lstSongs.Visible = True
lblList.Text = "Hide List"
Dim s As String
Dim s2 As String
Dim sR As String
s = filename
sR = StrReverse(s)
s2 = s.Substring(Len(s) - sR.IndexOf("\"))
lstSongs.Items.Add(s2)
Last edited by one_&_only; Aug 5th, 2006 at 08:10 PM.
-
Aug 6th, 2006, 08:17 AM
#8
Re: [2005] Need help with the openfiledialog and listview in my mp3 player
The Path class is provided specifically for manipulating file paths. If you want to get the file name from a path then you may not be surprised to hear that the Path.GetFileName method is the way to go:
VB Code:
lstSongs.Items.Add(IO.Path.GetFileName(ofd.FileName))
The simple things in life are often the most overlooked.
-
Aug 6th, 2006, 10:56 AM
#9
Thread Starter
Lively Member
Re: [2005] Need help with the openfiledialog and listview in my mp3 player
thanks alot jmcilhinney I never even knew I could do it that way
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|