![]() |
#1 |
Junior Member
Join Date: Apr 2002
Posts: 8
|
ID3 Tag in a Streaming mp3
Hi,
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). Thanks. cya. |
![]() |
![]() |
![]() |
#2 |
Moderator Alumni
Join Date: May 2000
Location: Next Door
Posts: 8,941
|
it uses meta tags, check out my article about the streaming standard at www.radiotoolbox.com/articles/
-Jay | Radio Toolbox.com |
![]() |
![]() |
![]() |
#3 |
Junior Member
Join Date: Apr 2002
Posts: 8
|
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. Any ideas? Thanks heaps. |
![]() |
![]() |
![]() |
#4 |
Moderator Alumni
Join Date: May 2000
Location: Next Door
Posts: 8,941
|
actually that param is a client header much like a User-Agent header.
-Jay | Radio Toolbox.com |
![]() |
![]() |
![]() |
#5 |
Junior Member
Join Date: Apr 2002
Posts: 8
|
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. |
![]() |
![]() |
![]() |
#6 |
Moderator Alumni
Join Date: May 2000
Location: Next Door
Posts: 8,941
|
no, this transaction is done when you send the HTTP request
example Connect to server Server Connected 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 -Jay | Radio Toolbox.com |
![]() |
![]() |
![]() |
#7 |
French Canadian
(Alumni) |
http://scastsrv2.shoutcast.com:8016/title
or http://scastsrv2.shoutcast.com:8016/7 I'd use that. Way more effecient. Aus -- NoisePort.Org, chronicles of the french canadian alien (Temporarly down during the move). |
![]() |
![]() |
![]() |
#8 |
Moderator Alumni
Join Date: May 2000
Location: Next Door
Posts: 8,941
|
hmm for a player that may be a little too inefficient especially if you are decoding the stream anyway.
-Jay | Radio Toolbox.com |
![]() |
![]() |
![]() |
#9 |
Junior Member
Join Date: Apr 2002
Posts: 8
|
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. Thanks. |
![]() |
![]() |
![]() |
#10 |
Moderator Alumni
Join Date: May 2000
Location: Next Door
Posts: 8,941
|
oh, ok in that case just use the urls provided above
if you have a server just simply put http://ip:port/title/ or http://ip:port/7/ 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. -Jay | Radio Toolbox.com |
![]() |
![]() |
![]() |
#11 |
Junior Member
Join Date: Apr 2002
Posts: 8
|
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.
-- snip 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> -- /snip With the same java code i can easily read the source of other webpages. Any reason for this 404? Thanks. |
![]() |
![]() |
![]() |
#12 |
Moderator Alumni
Join Date: May 2000
Location: Next Door
Posts: 8,941
|
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.
-Jay | Radio Toolbox.com |
![]() |
![]() |
![]() |
#13 |
Junior Member
Join Date: Apr 2002
Location: behind you
Posts: 3
|
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. |
![]() |
![]() |
![]() |
#14 |
Junior Member
Join Date: Apr 2002
Location: behind you
Posts: 3
|
oh. sorry guys. only read the first message in the stream. seeya.
|
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|