Talking[help].pls player

Posts 1–8 of 8 · Page 1 of 1
[help].pls player
Well, i think i have the basic's of a radio player Down..

but i need a little help

How the radio works

It's just a simple web browser and webclient You will put the link to Radiostation.pls in textbox1 Click the play button(button1)


it will use a wc to download and read the pls file and look for the link,
Put that link in webbrowser1.navigate which is hidden.. and music plays..

part i need help with

ok i have it almost done but i need help with the part where it gets the link,

Here is a sample of a radio.pls file but not all are the same.

Code:
[playlist]
numberofentries=1

File1=http://listen.wadiomedia.org/stream_128.php
Title1=Wadiomedia (128kbps)
Length1=-1
i want the program to extract the file1 but not all pls are file one...

how should i go about doing this?
I'm pretty sure you can use regex for this...

(waits for Jason/Kevin...)
Quote Originally Posted by Lolland View Post
I'm pretty sure you can use regex for this...

(waits for Jason/Kevin...)
Hassan is the string formatting pro.
Jason is the regex pro.

I only know basic string formatting :P.
I got it working but it removes the colons and slashes for some reason... :/
Use this function to get the link from the url:

[php]Function getLink(ByVal url As String)
Dim x As New Net.WebClient
Dim data As String = x.DownloadString(url).Trim
If Not data = vbNullString Then
Dim r() As String = data.Split(ChrW(10))
For Each n As String In r
If Not n.Trim = vbNullString Then
Dim q() As String = n.Split("=")
If q.Length > 1 Then
If q(1).StartsWith("http://") Or q(1).StartsWith("ftp://") Or q(1).StartsWith("https://") Then
Return q(1)
End If
End If
End If
Next
End If
End Function[/php]Then call it and use the extracted link:

[php]Dim link As String = getLink("http://mysite.com/radio.pls").ToString.Trim
If Not link = vbNullString Then
'Do whatever you want to do with the link...
End If[/php]
Ugh, got it working. It was because of my fail copy and paste from your code box.
[php] Private Function getLinkFromPlaylist(ByVal pathToPlaylist As String)
Dim playlist As String = IO.File.ReadAllText(pathToPlaylist)
Dim splitConfig() As String
splitConfig = playlist.Split(vbNewLine)
Dim fileRegex = New System.Text.RegularExpressions.Regex(".+://")
For Each value In splitConfig
If fileRegex.Match(value).Success Then
Dim s() As String
s = value.Split("=")
Return s(1)
End If
Next
Return Nothing
End Function[/php]

Feel free to use my or Hassan's one. His one is probably better to use but it's up to you. This requires the playlist to be saved locally so, lol. You could easily modify my code to read a playlist using a WebClient.
Yay Regex.

Code:
Imports System.Text.RegularExpressions
[php]
Private Function GetPlsLink(ByVal fileLocation As String) As String
Return IO.File.ReadAllLines(fileLocation).Where(Function( x) Regex.IsMatch(x, "http://.*?\.(org|net|co\.|me|com).*"))(0)
End Function
[/php]
thanks guys i will try it asap and let you know if i get errors
Posts 1–8 of 8 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us