Old 7th April 2002, 05:27   #1
DrOctopus
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.
DrOctopus is offline   Reply With Quote
Old 15th April 2002, 16:10   #2
Jay
Moderator Alumni
 
Jay's Avatar
 
Join Date: May 2000
Location: Next Door
Posts: 8,942
it uses meta tags, check out my article about the streaming standard at www.radiotoolbox.com/articles/
Jay is offline   Reply With Quote
Old 16th April 2002, 03:43   #3
DrOctopus
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.
DrOctopus is offline   Reply With Quote
Old 16th April 2002, 07:07   #4
Jay
Moderator Alumni
 
Jay's Avatar
 
Join Date: May 2000
Location: Next Door
Posts: 8,942
actually that param is a client header much like a User-Agent header.
Jay is offline   Reply With Quote
Old 17th April 2002, 05:02   #5
DrOctopus
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.
DrOctopus is offline   Reply With Quote
Old 17th April 2002, 05:47   #6
Jay
Moderator Alumni
 
Jay's Avatar
 
Join Date: May 2000
Location: Next Door
Posts: 8,942
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 is offline   Reply With Quote
Old 19th April 2002, 01:35   #7
Aus
French Canadian
(Alumni)
 
Aus's Avatar
 
Join Date: Dec 2001
Location: A shiny Igloo.
Posts: 333
Send a message via AIM to Aus
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).
Aus is offline   Reply With Quote
Old 19th April 2002, 02:08   #8
Jay
Moderator Alumni
 
Jay's Avatar
 
Join Date: May 2000
Location: Next Door
Posts: 8,942
hmm for a player that may be a little too inefficient especially if you are decoding the stream anyway.
Jay is offline   Reply With Quote
Old 19th April 2002, 04:42   #9
DrOctopus
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.
DrOctopus is offline   Reply With Quote
Old 19th April 2002, 05:14   #10
Jay
Moderator Alumni
 
Jay's Avatar
 
Join Date: May 2000
Location: Next Door
Posts: 8,942
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 is offline   Reply With Quote
Old 19th April 2002, 05:59   #11
DrOctopus
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.
DrOctopus is offline   Reply With Quote
Old 19th April 2002, 07:39   #12
Jay
Moderator Alumni
 
Jay's Avatar
 
Join Date: May 2000
Location: Next Door
Posts: 8,942
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 is offline   Reply With Quote
Old 22nd April 2002, 13:12   #13
wanton
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.
Attached Files
File Type: txt id3tagcargo.txt (4.2 KB, 332 views)
wanton is offline   Reply With Quote
Old 22nd April 2002, 13:15   #14
wanton
Junior Member
 
Join Date: Apr 2002
Location: behind you
Posts: 3
oh. sorry guys. only read the first message in the stream. seeya.
wanton is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump