Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Re: MP3 server with IO::Socket

by Anonymous Monk
on Mar 31, 2004 at 05:41 UTC ( #341206=note: print w/replies, xml ) Need Help??

in reply to Re: MP3 server with IO::Socket
in thread MP3 server with IO::Socket

MP3 Server in Perl ...hmmm interesting but you know what is more interesting ...
Here is the Bash version ;)
#!/bin/bash DIR=`pwd` echo "BASH_MP3D - A Streaming MP3 Server in Bash " echo "And You are as crazy as me if you are running this .... " echo echo "Generating Playlist .....Plz wait" PLAYLIST=`find $DIR -name *.mp3` NUM=`echo $PLAYLIST | wc -w` echo "done." echo "Listening on 5700 ....." { while true do #get seconds for random number rand=`date | cut -d ':' -f 3 |cut -d ' ' -f1` let "rand += 1" while [ "$rand" -gt "$NUM" ] do let "rand -= $NUM" done SONG=`echo $PLAYLIST | cut -d ' ' -f$rand` #Now we play the random song SONG echo "Playing $SONG ... " >& 2 echo "HTTP/1.0 200 OK"; echo "Content-Type: audio/x-mp3stream"; echo "Cache-Control: no-cache "; echo "Pragma: no-cache "; echo "Connection: close "; echo "x-audiocast-name: BASH MP3 Server"; echo; echo; dd if=$SONG bs=1024 done }| nc -l -p 5700

Replies are listed 'Best First'.
Re^3: MP3 server with IO::Socket
by Anonymous Monk on Sep 21, 2004 at 19:39 UTC
    Hey, I thought this was very clever, but thought I'd shorten it into the worlds smallest (and least feature-full) MP3 server:
    #!/bin/bash PLAYLIST=`find ./content -name *.mp3` NUM=`echo $PLAYLIST | wc -w` { while true; do rand=$(($RANDOM%$NUM)) song=`echo $PLAYLIST | cut -d ' ' -f$rand` echo "HTTP/1.0 200 OK\nContent-Type: audio/x-mp3stream\n\n" dd if=$song bs=1024 done } | nc -l -p 8020
    Broadcasting to the entire world! :)
      No, this would be the shortest.. and a command line command:
      while true; do NUM=`find /home/MP3/Bob_marley/*.mp3 | wc -l`; rand=$(( +$RANDOM%$NUM)); song=`find /home/MP3/Bob_marley/*.mp3 | sed -n ${rand +}p`; echo "HTTP/1.0 200 OK\nContent-Type: audio/x-mp3stream\n\n"; dd +if="$song" bs=1024; done | nc -l -p 8020
      -- --

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://341206]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2020-08-10 07:14 GMT
Find Nodes?
    Voting Booth?
    Which rocket would you take to Mars?

    Results (56 votes). Check out past polls.