Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

miniproject - ServerXMLHTTP get info for 'net radio

Status
Not open for further replies.

ChainsawJoe

Programmer
Dec 5, 2000
154
GB
I'm really getting into ServerXMLHTTP and XMLHTTP recently, incorporating its functionality into so many new projects within the past month that its just a matter of time before I've a) exhausted all possible uses for it or b) recreated everything google have done recently.

Hmm.. neither likely. how about c) get told off for wasting time at work and told to actually get on with my job?

Anyway. One more use here: since I recently used it to process a succession of xml feeds and download all images mentioned within the feed onto a local server in order to duplicate the content of a site without sucking bandwidth, I wondered what else it can access.

I'm currently trying to display the currently playing tune from a shoutcast radio station via the stream address used in winamp, spoofed the user-agent of the asp page to be winamp (cos otherwise you just get the contents of the stream's shoutcast html homepage) and used a selection of versions of xmlhttp and serverxmlhttp, each with different results, each failing.

The best I could get was when using MSXML2.XMLHTTP.4.0 - then it hangs. Doesn't get past the Send() call. Dooesn't erro, just doesn't do anything else..

Here's what I've got for this lil scripty - any tips, pointers, downright flaming are welcome :p
Code:
on error resume next

dim i : i=0
dim oXMLHTTP : set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.4.0")
dim oStream : set oStream = createobject("ADODB.Stream")

oXMLHTTP.Open "POST", "[URL unfurl="true"]http://64.62.252.134:6670",[/URL] true
oXMLHTTP.setRequestHeader "User-Agent","WinampMPEG/5.1"
oXMLHTTP.Send

'-- only some (server)xmlhttps support waitforresponse
while i<1000 and oXMLHTTP.readyState<>4
	oXMLHTTP.waitForResponse 3
	i=1+1
	response.Write ". "
	response.Flush
wend

response.write oXMLHTTP.getAllResponseHeaders 
response.flush


if err.number<>0 then
	response.Write err.number & "<br /> " & err.Description & "<br />" & err.Source & "<hr />" & vbcrlf
	response.Write oXMLHTTP.parseError.Reason
end if

set oStream = nothing
set oXMLHTTP = nothing	
	
on error goto 0

By the way - that code sometimes seems to not close any connections, so you might need to do an iireset every so often if you run it enough.. else you get a "HTTP 403.9 - Access Forbidden: Too many users are connected" error

If I use msxml2.xmlhttp.4.0, it hangs.
If I use msxml2.xmlhttp.5.0, it fails with this message "The connection with the server was terminated abnormally" at the waitforresponse line.
Same if I use msxml.serverxmlhttp.

ServerMSXMLHTTP.4.0 = "Access is denied" at .Send()
ServerMSXMLHTTP.3.0 = Timeout

I assume that it might be something to do with the fact that it's streaming media and as such can never have an entire "file" to be downloaded, hence the code just hangs.

I'm guessing that what i'm trying to do here isn't actually possible, but just in case... :p

Appreciate any input!

Again - there's no real point to this and I'm sure I could achieve it by some other method, but was just.. y'know.. wonderin.. :)

--------------------------------------------------
- better than toast.
Penguins - better than --------------------------------------------------
 
Best solution would probably to write a COM object to handle this. It looks like the Shoutcast server needs some extra headers to return music information in the headers of it's HTTP response. The important header is the last one, which specifies how much of the stream to skip before you will get to the beginning of the meta information for the song. The first byte of the streamed data is the size of the meta data field in bytes/16. If the meta information is shorter than that amount * 16 then the rest of the field is padded out with ASCII character 00's to fit the byte size reported.

So basically you will need to add a header to your request that signifies you are a client that can accept meta information. Here is some information I got while searching for the parts I don't remember:
The biggest problem you are going to run into is that Byte handling in VBScript sucks pretty bad. Anyways, hope this helps,

-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top