|
-
Jul 17th, 2010, 08:41 PM
#1
Thread Starter
New Member
[RESOLVED] Having trouble with Listbox
Hey guys im working on a small mp3 streaming client and im having trouble getting a listbox to display the .mp3 files in a specific directory on my server. I wanna have this listbox display all the different mp3 tracks in my directory so when the user double clicks the track name in the listbox it will redirect the mediaplayers url to start the stream of the song. So can anyone help me with this thanks in advanced
-
Jul 18th, 2010, 02:11 AM
#2
Re: Having trouble with Listbox
vb Code:
mypath = "c:\mp3s\" 'change to suit fname = dir(mypath & "*.mp3") do while len(fname) > 0 list1.additem fname fname = dir loop
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jul 20th, 2010, 10:56 PM
#3
Thread Starter
New Member
Re: Having trouble with Listbox
what do i dim mypath,fnam,and dir as?
-
Jul 20th, 2010, 11:19 PM
#4
Re: Having trouble with Listbox
What kind of server is it?
Software I use and highly recommend: Opera, Miranda IM, Peerblock, Winamp, Unlocker Assistant, JoyToKey, Virtual CloneDrive, Secunia PSI, ExplorerXP, GOM Player, Real Alternative, Quicktime Alternative,Sumatra PDF, and non-freeware: Photoshop and VB6( ).
My codebank: AllRGB, Rounded Rectangle(math), Binary Server, Buddy Paint, LoadPictureGDI+, System GUID/Volume Serial, HexToAsc, List all processes and their paths, quasiString matching
Strings(search, extraction, retrieval etc): Retrieve BBCode Link from HTML, RemoveBetween ()'s, strFindBetween(str1,str2), Insert text in HTML, HTML - GetSpanByID
-
Jul 20th, 2010, 11:24 PM
#5
Thread Starter
New Member
Re: Having trouble with Listbox
 Originally Posted by FireXtol
What kind of server is it?
i have all the .mp3 files hosted on a website. How can i get them to showup in the listvbox?
-
Jul 20th, 2010, 11:26 PM
#6
Thread Starter
New Member
Re: Having trouble with Listbox
the server is just a linux VPS.
-
Jul 20th, 2010, 11:41 PM
#7
Re: Having trouble with Listbox
So you're probably using Apache, basically some HTTP server? Is the directory they're in public?
You'll need to use something like Inet or Winsock to request the directory contents, then parse the response.
Software I use and highly recommend: Opera, Miranda IM, Peerblock, Winamp, Unlocker Assistant, JoyToKey, Virtual CloneDrive, Secunia PSI, ExplorerXP, GOM Player, Real Alternative, Quicktime Alternative,Sumatra PDF, and non-freeware: Photoshop and VB6( ).
My codebank: AllRGB, Rounded Rectangle(math), Binary Server, Buddy Paint, LoadPictureGDI+, System GUID/Volume Serial, HexToAsc, List all processes and their paths, quasiString matching
Strings(search, extraction, retrieval etc): Retrieve BBCode Link from HTML, RemoveBetween ()'s, strFindBetween(str1,str2), Insert text in HTML, HTML - GetSpanByID
-
Jul 21st, 2010, 05:27 PM
#8
Thread Starter
New Member
Re: Having trouble with Listbox
 Originally Posted by FireXtol
So you're probably using Apache, basically some HTTP server? Is the directory they're in public?
You'll need to use something like Inet or Winsock to request the directory contents, then parse the response.
yes it is a simple http apache server and there in a public directory i dont have the .htaccess file restricting anything from viewing it.
-
Jul 21st, 2010, 05:45 PM
#9
Re: Having trouble with Listbox
So how far along are you? Do you need help with the downloading of the directory list from the server, and/or parsing the response?
Software I use and highly recommend: Opera, Miranda IM, Peerblock, Winamp, Unlocker Assistant, JoyToKey, Virtual CloneDrive, Secunia PSI, ExplorerXP, GOM Player, Real Alternative, Quicktime Alternative,Sumatra PDF, and non-freeware: Photoshop and VB6( ).
My codebank: AllRGB, Rounded Rectangle(math), Binary Server, Buddy Paint, LoadPictureGDI+, System GUID/Volume Serial, HexToAsc, List all processes and their paths, quasiString matching
Strings(search, extraction, retrieval etc): Retrieve BBCode Link from HTML, RemoveBetween ()'s, strFindBetween(str1,str2), Insert text in HTML, HTML - GetSpanByID
-
Jul 21st, 2010, 05:50 PM
#10
Thread Starter
New Member
Re: Having trouble with Listbox
 Originally Posted by FireXtol
So how far along are you? Do you need help with the downloading of the directory list from the server, and/or parsing the response?
yes im still trying to figure out that but ive never done that before so i would have no clue were to start from :/
-
Jul 21st, 2010, 05:59 PM
#11
Re: Having trouble with Listbox
I'd suggest Inet. Goto Components | Controls and check: Microsoft Internet Transfer Control
Add the control to a form and add some code:
vb Code:
Dim strDirs As String
strDirs = Inet1.OpenURL(YOUR_URL_HERE)
Most likely your server will return a list of links. You can use StrFindBetween, for instance, see the link in my sig under Strings. You'll want to find: "<a href=""" to """>", then perform an Instr on the string between those two strings. In the Instr determine if there's a forward slash "/", and if so treat that as a directory, and not a file. If it's a file(and not a directory), then instr for the ".MP3" extension, and if so add it to the list.
Now, add a List1, and try this:
vb Code:
Dim strDirs As String, strResult As String
Dim X As Long, Y As Long
strDirs = Inet1.OpenURL("some_url_here")
X = InStr(strDirs, "<a href=""")
Do While X > 0
X = X + Len("<a href=""")
Y = InStr(X, strDirs, """>")
If X And Y Then
strResult = LCase$(Mid$(strDirs, X, Y - X))
If InStr(strResult, "/") Then
'directory
ElseIf InStr(strResult, ".mp3") Then
'mp3 file
List1.AddItem Mid$(strDirs, X, Y - X) 'names are case sensitive, so re-fetch this
Else
'other file
End If
Else
Exit Do 'we're out of string, there are no matches
End If
X = InStr(Y, strDirs, "<a href=""")
Loop
Last edited by FireXtol; Jul 21st, 2010 at 06:15 PM.
Software I use and highly recommend: Opera, Miranda IM, Peerblock, Winamp, Unlocker Assistant, JoyToKey, Virtual CloneDrive, Secunia PSI, ExplorerXP, GOM Player, Real Alternative, Quicktime Alternative,Sumatra PDF, and non-freeware: Photoshop and VB6( ).
My codebank: AllRGB, Rounded Rectangle(math), Binary Server, Buddy Paint, LoadPictureGDI+, System GUID/Volume Serial, HexToAsc, List all processes and their paths, quasiString matching
Strings(search, extraction, retrieval etc): Retrieve BBCode Link from HTML, RemoveBetween ()'s, strFindBetween(str1,str2), Insert text in HTML, HTML - GetSpanByID
-
Jul 21st, 2010, 06:19 PM
#12
Thread Starter
New Member
Re: Having trouble with Listbox
its not returning any values into the listbox
-
Jul 21st, 2010, 06:20 PM
#13
Thread Starter
New Member
Re: Having trouble with Listbox
oh i got it to work thank you for all your help
-
Jul 21st, 2010, 06:23 PM
#14
Re: Having trouble with Listbox
 Originally Posted by GGGuardian
oh i got it to work thank you for all your help 
You're welcome.
Software I use and highly recommend: Opera, Miranda IM, Peerblock, Winamp, Unlocker Assistant, JoyToKey, Virtual CloneDrive, Secunia PSI, ExplorerXP, GOM Player, Real Alternative, Quicktime Alternative,Sumatra PDF, and non-freeware: Photoshop and VB6( ).
My codebank: AllRGB, Rounded Rectangle(math), Binary Server, Buddy Paint, LoadPictureGDI+, System GUID/Volume Serial, HexToAsc, List all processes and their paths, quasiString matching
Strings(search, extraction, retrieval etc): Retrieve BBCode Link from HTML, RemoveBetween ()'s, strFindBetween(str1,str2), Insert text in HTML, HTML - GetSpanByID
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
|