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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|