online radio

Discuss anything about technology or computers here, other than programming.

Postby ludakot on Sat Sep 09, 2006 5:34 pm

I use a perl script (just like for everything else :p) here is the source
Code: Select all
#!/usr/bin/perl -w
use strict;
use IO::Socket;

#get the port to bind to or default to 8000
my $port = $ARGV[0] || 31337;

#ignore child processes to prevent zombies
$SIG{CHLD} = 'IGNORE';

#create the listen socket
my $listen_socket = IO::Socket::INET->new(LocalPort => $port,
                                          Listen => 10,
                                          Proto => 'tcp',
                                          Reuse => 1);
#make sure we are bound to the port
die "Cant't create a listening socket: $@" unless $listen_socket;

warn "Server ready. Waiting for connections ... \n";

#wait for connections at the accept call
while (my $connection = $listen_socket->accept)
{   
    my $child;
    # perform the fork or exit
    die "Can't fork: $!" unless defined ($child = fork());
    if ($child == 0)
    {   #i'm the child!
   
        #close the child's listen socket, we dont need it.
        $listen_socket->close;
       
        #call the main child rountine
        play_songs($connection);
       
        #if the child returns, then just exit;
        exit 0;
    }
    else
    {   #i'm the parent!
   
        #who connected?
        warn "Connecton recieved ... ",$connection->peerhost,"\n";

        #close the connection, the parent has already passed
        #   it off to a child.
        $connection->close();
       
    }
    #go back and listen for the next connection!
}

sub play_songs
{   
    my $socket = shift;
   
    #get all the possible songs
    open PLAYLIST, "playlist.m3u" or die;
    my @songs = <PLAYLIST>;   
    close PLAYLIST;
    chomp @songs;

    #seed the rand number generator
    srand(time / $$);
   
    #loop forever (or until the client closes the socket)
    while()
    {
       
        #print the HTTP header.  The only thing really necessary
        #   is the first line and the trailing "\n\n"
        #   depending on your client (like xmms) you can also
        #   send song title etc.

       
        #get a random song from your playlist
        my $song = $songs[ rand @songs ];
       
        #what song are we playing
        warn( "play song: $song\n");
        #open the song, or continue to try another one
        open (SONG, $song) || next;

        binmode(SONG); #for windows users
    print $socket "ICY 200 OK\r\n";
        print $socket "Content-Type: audio/mpeg \r\n";
        print $socket "Cache-Control: no-cache \r\n";
        print $socket "Pragma: no-cache \r\n";
        print $socket "Connection: close \r\n";
    print $socket "icy-name: $song \r\n";
        print $socket "icy-genre: Music for open minded people \r\n";
        print $socket "icy-url: http://localhost \r\n";
        print $socket "icy-notice1:This stream requires Winamp \r\n";
        print $socket "icy-notice2:Perl Streamer v0.1a \r\n";
        print $socket "icy-metadata: 1 \r\n\r\n";
        my $read_status = 1;
        my $print_status = 1;
        my $chunk;

        # This parts print the binary to the socket
        #   as fast as it can.  The buffering will
        #   take place on the client side (it blocks when full)
        #   because this is *not* non-blocking IO
        #
        #the read will return 0 if it has reached eof
        #
        #the print will return undef if it fails
        #   (ie the client stopped listening)
        #
        while( $read_status  && $print_status )
        {   
            $read_status = read (SONG, $chunk, 1024);
            if( defined $chunk && defined $read_status)
            {   
                $print_status = print $socket $chunk;
            }
            undef $chunk;
        }
        close SONG;
       
        unless( defined $print_status )
        {   
            $socket->close();
            exit(0);
        }
    }
}

For the record I didn't make this script, I got it from perlmonks.
Have fun Smile
ludakot
Contributer
Contributer
 
Posts: 22
Joined: Wed Sep 06, 2006 1:21 am
Location: http://ludakot.com

Postby topolab on Sat Sep 09, 2006 9:18 pm

for radio and sat tv try this:

www.wuup.com
Image -= irc.EFNET.nl : #AIVAnet , #salonica =-
Image -= 0day symbian+pda -> http://aivanet.info =-
topolab
Regular
Regular
 
Posts: 134
Joined: Sun Sep 11, 2005 7:31 am
Location: macedonia-north greece

Radio Streamming

Postby thestrifer on Sun Sep 10, 2006 12:01 am

I highly recommend ShoutCast DNAS Server, or Icecast, or SteamCast...

I particullary prefer shoutcast, and you can use sc_trans utilitie to broadcast stored mp3s at a linux machine =D without a soundcard.. It just transcode the mp3 for the server... pretty cool..

I've some ideas about it, doing a scripting to turn sc_trans into a alive song request tool, it'll be nice...

http://www.radiotoolbox.com
http://www.shoutcast.com
http://www.icecast.org <- OpenSource from Xiph Group

Thats it, i've some knowledge about internet streamming, feel free to ask...
Bye
___________________
if ( $knowledge == $power) { $world = your; }
AMD Athlon 64 3400+ Socket 754 @ 2.43GHz
Asus K8V-X SE Offboard
1x512mb Ram Kingstone
NVidia GeForce FX5200 128MB AGP 8x
thestrifer
Contributer
Contributer
 
Posts: 21
Joined: Sat Sep 09, 2006 11:13 am
Location: Brazil

Postby TigerWolf on Sun Sep 10, 2006 1:01 am

Im not one for setting up a server, but i do like listening in.

I recon the best music streaming site thats out there at the moment would have to be di.fm. It has some great streams with alot of variety for every possible mood i could be in.
TigerWolf
Regular
Regular
 
Posts: 76
Joined: Fri Sep 08, 2006 10:33 am

Re: online radio

Postby FuRy on Sun Sep 17, 2006 6:11 pm

slave wrote:lets talk about online radio streaming
which software is best and how we can operate and do i can use phoenix hosting for radio purpose?
let me inform
ok guyz start sharing


I always used Winamp Shoutcast and I think that's easy to use it.
FuRy
Newbie
Newbie
 
Posts: 15
Joined: Sun Sep 17, 2006 5:50 pm

Postby HxC on Sat Sep 23, 2006 1:17 pm

i think Windows media player is a good place to look for an online radio, also there are a lot you can find in the winamp web site i guess
HxC
Contributer
Contributer
 
Posts: 23
Joined: Sat Sep 23, 2006 4:32 am

what about .rm and .dat files

Postby slave on Tue Sep 26, 2006 11:04 am

suppose we are using shoutcast for streaming and winamp for broadcasting then how we can play .rm files and .dat files on it ?
Death Angel
slave
Contributer
Contributer
 
Posts: 71
Joined: Sun Mar 26, 2006 3:03 pm
Location: Death Town

Re: what about .rm and .dat files

Postby bat on Wed Sep 27, 2006 12:59 pm

slave wrote:suppose we are using shoutcast for streaming and winamp for broadcasting then how we can play .rm files and .dat files on it ?


To get around that little problem, I simply slid the rm files through a recorder like total recorder which records the output from your soundcard in a wav format. Then simply convert that to mp3. There's probably a better way of doing but I haven't found it either. Oh, by the way, has anyone used the jaizlur radio automation software? it's supposed to be pretty good I heard.
Failure is not an option, it comes bundled with your microsoft products.
bat
Regular
Regular
 
Posts: 86
Joined: Tue Jul 04, 2006 2:10 am
Location: canada

Postby vlajke on Sat Sep 30, 2006 7:19 pm

Can someone leave link to download windows version and some instruction how to install/setup etc.
vlajke
Newbie
Newbie
 
Posts: 17
Joined: Sat Sep 30, 2006 1:48 pm

Postby Rage on Sun Oct 08, 2006 4:20 am

ShoutCast works really well. You can basically control what's playing via your winamp. I know of a few sites that use it, and the quality is really good.
Rage
Contributer
Contributer
 
Posts: 31
Joined: Sun Oct 08, 2006 3:20 am

Previous

Return to Technology

Who is online

Users browsing this forum: No registered users and 1 guest

cron