Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-14-2007, 02:30 PM   #1
FrodoBaggins
Fellowship of the Script
 
Join Date: Jan 2006
Location: the Netherlands / heading to the UK
Posts: 629
Post web radio getting stream info

I'm trying to retrieve the (id3?) info from a streaming web radio in Flash. Say I have a connection to http://scfire-dll-aa04.stream.aol.com:80/stream/1022 to stream live radio from in Flash. It's no problem setting up the Sound and SoundChannel objects. The problem is trying to retrieve the ID3-tag for the stream, since the event Event.ID3 is never triggered. (This probably has to do with the fact that the file never fully loads.)

Is there any other way to get the stream info?
FrodoBaggins is offline   Reply With Quote
Old 10-16-2007, 02:18 PM   #2
FrodoBaggins
Fellowship of the Script
 
Join Date: Jan 2006
Location: the Netherlands / heading to the UK
Posts: 629
Default

Nobody knows?

I know for sure that there is (something like) an ID3-tag sent with the stream, since winAmp is able to show that. I also found out that meta data is sent every X bytes. See below:

Network received: 745363 bytes
Server: Firehose Ultravox/SHOUTcast Relay Server/Linux v2.5.5
Content-Type: audio/mpeg
Metadata received: 142 bytes
Metadata interval: 24576 bytes
Stream name: 181.fm - The Buzz (Your Alternative Station!)
Current title: Chevelle - I Get It

So I guess you should be able to retrieve this info with AS3 as well. How? I don't know. I hope somebody can help me with this.

Thanks in advance,

-FB
FrodoBaggins is offline   Reply With Quote
Old 10-17-2007, 05:28 PM   #3
FrodoBaggins
Fellowship of the Script
 
Join Date: Jan 2006
Location: the Netherlands / heading to the UK
Posts: 629
Default

Ha, let me answer my own question in post #2.
When you know the server IP and port you can open a socket connection to it and retrieve the stream information as I found on the winAmp forums.

I took this piece of PHP code and tested a bit with it, to see if it has the desireable results.
PHP Code:
<?php
    $ip 
"205.188.215.231";
    
$port "8016";
    
    
$open fsockopen($ip,$port);
    if (
$open) {
        
fputs($open,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
        
$read fread($open,1000);
        
$text explode("content-type:text/html",$read);
        
$text explode(",",$text[1]);
    } 
    else { 
        
$er="Connection Refused!"
    }
    if (
$text[1]==1) { $state "Up"; } else { $state "Down"; }
    if (
$er) { 
        echo 
$er
        exit; 
    }
    echo 
"<font face=verdana size=1>
    Listeners: 
$text[0] of $text[3] ($text[4] Unique)<br>
    Listener Peak: 
$text[2]<br>
    Server State: <b>
$state</b><br>
    Bitrate: 
$text[5] Kbps<br>
    Current Song: 
$text[6]<br>
    </font>"
;
?>
You can see this script at work at: http://ansuz.nl/bla/streamInfo.php

It does give you almost all the information you want. The only thing I'm missing is the stream name.
The thing is, this is all nice and fun, but useless when you don't know the server's ip and port. So let's say you're able to get all radio stations from shoutcast.com, but they only provide you a list with urls to use to tune in to the station.
My test case with this showed a big problem with this method right away.
The URL I used is: http://www.snakenetmetalradio.com/Snakenet-96k.asp
This URL is located on the following IP: 130.94.243.192
BUT, the actual shoutcast server is located on this IP: 205.188.215.231 and port: 8016.
So even if you were able to retrieve the IP of an url some way in Flash, you're still only guessing that the shoutcast server is running on the same IP. After that you also have to guess the port number.

All in all I didn't really get any further, unless I decide to build my own list with radio stations in XML and fill that with the right info (like IP, port, stream name, etc.) myself.

Well, I love how this monologue is going, but hopefully this will help somebody some other day.

Or maybe there is someone able to help me with this?

Last edited by FrodoBaggins; 10-17-2007 at 05:31 PM. Reason: forgot to post the url to the working PHP script
FrodoBaggins is offline   Reply With Quote
Old 10-18-2007, 12:24 PM   #4
FrodoBaggins
Fellowship of the Script
 
Join Date: Jan 2006
Location: the Netherlands / heading to the UK
Posts: 629
Default

Interesting post on http://weblogs.macromedia.com/produc.../06/index.html
Quote:
Unable to obtain ID3 tags from MP3s loaded into SWF

(TechNote) In Flash Player 9, the Sound.id3 property is not available when using Sound.loadSound (or its ActionScript 3.0 equivalent, Sound.load) to load an external MP3 file from a different domain than the Flash Player movie (SWF) file unless a policy file exists on the MP3 file's server. The policy file must permit access by the domain of the SWF that is attempting to read ID3 tag information from the MP3 file.
FrodoBaggins is offline   Reply With Quote
Old 10-21-2007, 08:58 AM   #5
FrodoBaggins
Fellowship of the Script
 
Join Date: Jan 2006
Location: the Netherlands / heading to the UK
Posts: 629
Default

Great! now there are different ways to get the same info, but if one way works, the other won't! Ah well, I guess we'll get there some time!
Compare this url the the php script above.
http://www.smackfu.com/stuff/programming/shoutcast.html
FrodoBaggins is offline   Reply With Quote
Old 10-21-2007, 07:12 PM   #6
icktoofay
Senior Member
 
Join Date: Sep 2006
Posts: 381
Default

Hmmm... Seems simple enough to do with PHP... Ahh, well. I'll try to make a little java app which you can call with PHP.
__________________
I am no longer an active ActionScript.org member - sorry!
icktoofay is offline   Reply With Quote
Old 10-21-2007, 08:44 PM   #7
FrodoBaggins
Fellowship of the Script
 
Join Date: Jan 2006
Location: the Netherlands / heading to the UK
Posts: 629
Default

I never said it was really hard using PHP, just found out that there is more than one way leading to Rome!
Thanks in advance any way!
FrodoBaggins is offline   Reply With Quote
Old 10-22-2007, 01:47 AM   #8
icktoofay
Senior Member
 
Join Date: Sep 2006
Posts: 381
Default

Still, I like PHP, but it's just not that good for sockets (in my opinion). I prefer java for development with sockets. Also, there was a slight (okay, maybe more...) delay, so it should be done in a few hours.

Edit: Also, that article you provided is proving very useful.
__________________
I am no longer an active ActionScript.org member - sorry!
icktoofay is offline   Reply With Quote
Old 10-22-2007, 02:36 AM   #9
icktoofay
Senior Member
 
Join Date: Sep 2006
Posts: 381
Default

It's done. It should work with any Shoutcast stream. It will output something like this:
Code:
<?xml version="1.0"?>
<metadata>
        <StreamUrl></StreamUrl>
        <icy-name>181.fm - The Buzz (Your Alternative Station!)</icy-name>
        <icy-url>http://www.181.fm</icy-url>
        <icy-pub>1</icy-pub>
        <icy-genre>Alternative Rock</icy-genre>
        <StreamTitle>Beastie Boys - Sabotage (Clean Version)</StreamTitle>
        <icy-br>128</icy-br>
        <icy-metaint>24576</icy-metaint>
        <icy-notice2>Firehose Ultravox/SHOUTcast Relay Server/Linux v2.5.5<BR></icy-notice2>
        <icy-notice1><BR>This stream requires <a href="http://www.winamp.com/">Winamp</a><BR></icy-notice1>
        <content-type>audio/mpeg</content-type>
</metadata>
To change the url that it fetches the data from, modify metadata.php's system statement. It should be fairly simple to change.
Code:
...adata [ip/domain] [port] [path]")...
Also, the machine it runs on must have the java jre installed. If it doesn't, then it will show an error message. Hope that helps!
Attached Files
File Type: zip shoutcast_metadata.zip (4.2 KB, 763 views)
__________________
I am no longer an active ActionScript.org member - sorry!

Last edited by icktoofay; 10-22-2007 at 02:46 AM.
icktoofay is offline   Reply With Quote
Old 10-22-2007, 07:47 AM   #10
FrodoBaggins
Fellowship of the Script
 
Join Date: Jan 2006
Location: the Netherlands / heading to the UK
Posts: 629
Default

awesome mate! I'll try and test this as soon as I got time. Than after that I'll (try and) disect it to see how it works, cause that is the most interesting part to me.
FrodoBaggins is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Info out of radio buttons components miguelangelo Components 4 10-08-2007 03:20 PM
combobox and radio info not posting to phpfile lelales Components 10 06-27-2006 12:01 AM
flash radio stream player: possible ? alexandre_lab ActionScript 2.0 4 09-26-2004 11:26 AM
Old and New in ActionScript Madokan ActionScript 2.0 3 01-04-2004 06:37 PM
Shoutcast Radio Stream - Sound.loadSound("Shoutcast" , isStreaming); Funky ActionScript 1.0 (and below) 2 08-08-2002 03:30 AM


All times are GMT. The time now is 10:40 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.