View Full Version : ID3 Tag in a Streaming mp3
7th April 2002, 05:27
I'm making a small program in java to obtain the track and artist name from a streaming mp3. I've managed to connect to the stream however the ID3 tag doesnt appear to be contained within the stream.
Does anyone know how winamp obtains the track info and artist name of a streaming mp3? (I'm connecting to a shoutcast stream).
15th April 2002, 16:10
it uses meta tags, check out my article about the streaming standard at www.radiotoolbox.com/articles/
16th April 2002, 03:43
Hey, thanks for replying.
I checked out your site and its awesome, lots of useful info.
So I gather to make the stream send the song title I need to first write to the stream with 'icy-metadata:1\r\n' to let it know i can handle song titles.
I'm a little confused at how to write this to the stream. Do I write a string to the stream (which I'll be reading from later) in the form "POST <whatever>" where whatever is the metadata? Or can I simply write the metadata to the stream. Either way, after I've written to the stream and try to then create a reader for the stream, I get an 'Unexpected end of file from server' error.
16th April 2002, 07:07
actually that param is a client header much like a User-Agent header.
17th April 2002, 05:02
hmm ok, i'm still a little confused about sending information to the server. Here's what I've got mapped out in my head.
I have the IP and port of the mp3 stream. Now I figure before I can obtain the title I have to send a little bit of information to the server to let it know I am expecting the title. Once I've done this I can then read the first X bytes of the stream to obtain the title information.
Now do I send the 'icy-metadata:1\r\n' string to the same port that I'm connecting to to read the streaming mp3? Will this port (which the server sends the mp3 out on) be ready to recieve data?
When I actually send this data (icy-metadata:1\r\n) do i simply send it by itslef as a string....or does the string need something like 'POST' prepended to it?
Sorry if I'm going over the same ground again and again.
Thanks heaps for your help, later.
17th April 2002, 05:47
no, this transaction is done when you send the HTTP request
Connect to server
Tell Server what we want (GET / HTTP/1.0\r\nUser-Agent: MyClient\r\nicy-metadata: 1\r\n\r\n)
Server responds with appropriate data.
End Connection to server
19th April 2002, 01:35
I'd use that. Way more effecient.
19th April 2002, 02:08
hmm for a player that may be a little too inefficient especially if you are decoding the stream anyway.
19th April 2002, 04:42
What were those url's supposed to do?
They appear to be 'down'.....
Also, this isnt for a player. What I'm trying to do is just get the title and artist of the currently playing song. I'm using this information with another program that I'm writing. I'm not actually writing a player to decode the mp3 stream.
Is it cool if i post my java code here? its not very long at all.
19th April 2002, 05:14
oh, ok in that case just use the urls provided above
if you have a server just simply put
If you are using a server version previous the 1.8.9 then you should just parse the title out of the main status page. To get to any of these pages from an application you must pass Mozilla in the user-agent field otherwise you will just get a stream.
19th April 2002, 05:59
ok cool. well the url's work in the browser, i can get the title of the track currently playing. However, when i attempt to read the webpage (either the /title or the /7) in my Java program i get the following message coming throught the stream.
ICY 404 Resource Not Found
icy-notice1:<BR>SHOUTcast Distributed Network Audio Server/SolarisSparc v1.8.10<BR>
icy-notice2:The resource requested was not found<BR>
With the same java code i can easily read the source of other webpages. Any reason for this 404?
19th April 2002, 07:39
As I said in my post above, you must pass Mozilla somewhere in your User-Agent Tag as part of your request header, otherwise the server will assume you are a media player trying to find the stream.
22nd April 2002, 13:12
the id3 tag is made up of the last 128bytes of the file.
This causes a problem if you dont have access to the whole file due to an incomplete download.
an example of how to interpret this information is attached.
22nd April 2002, 13:15
oh. sorry guys. only read the first message in the stream. seeya.
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.