well this is offtopic ...
i don't really have a m9u question, i would have posted
to [email protected] then.
but i needed a webinterface for playing music remotely,
lets not discuss that approach.
i decided to use m9u with a rc cgi script, i wanted to
keep things really simple - i would be happy if you com-
ment on the rc webinterface part.
best regards, yoshi
#!/usr/plan9/bin/rc
DATA=/var/data/music
CTRL=/var/nostromo/htdocs/murc/face
fn header {
echo 'Content-Type: text/html
<!DOCTYPE HTML>
<html><head>
<title>'$1'</title>
<style>'
cat style.css
echo '</style>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="refresh" content="15;url=/">
</head><body>'
}
fn footer {
echo '<p>murc - rc m9u interface</p>'
echo '</body></html>'
}
fn dunno {
header
echo '<p>i dunno ..</p>'
footer
}
fn draw {
sleep 1
ifs='
'
stat=`{sed 1q $CTRL/event}
curr=`{echo $stat | sed 's:.... '$DATA'/::'}
list=`{sed 's:^'$DATA'/::' $CTRL/list}
count=`{seq 1 $#list}
saved=`{ls lists/}
dirs=`{ls $DATA}
header $"curr
echo '<ul id="dirs">'
for(d in $dirs) {
subs=`{ls $DATA/$d}
echo '<li><a href="/add/'$d'">'$d'</a>'
echo '<ul>'
echo '<li><a href="/add/'$d'/'$subs'">'$subs'</a></li>'
echo '</ul></li>'
}
echo '</ul>'
echo '<p>saved lists: '
echo '<a href=/load/'$saved'>'$saved'</a>'
echo '| <a href="/clear">clear</a>'
echo '</p>'
echo '<h1>'$"curr'</h1>'
echo '<div id="ctrl"><a href="/play">play</a> | <a
href="/stop">stop</a> | <a href="/skip">skip</a></div>'
echo '<div id="list"><ul>'
echo '<li><a href="/jump/'$count'">'$count' '$list'</a></li>'
echo '</ul></div>'
footer
}
# main
if(test ! -d $CTRL) {
header
echo '<p>9P dir '$CTRL' does not exist ..</p>'
footer
exit
}
if(test ! -w $CTRL/list) {
header
echo '<p>m9u is not mounted in '$CTRL' ..</p>'
footer
exit
}
if(test ! -d $DATA) {
header
echo '<p>the directory '$DATA' does not exist ..</p>'
footer
exit
}
switch($PATH_INFO) {
case /
draw
case /play
echo stop > $CTRL/ctl
echo play > $CTRL/ctl
draw
case /stop
echo stop > $CTRL/ctl
draw
case /add/*
find `{echo $PATH_INFO | sed 's:^/add:'$DATA':'} -type f -iname '*.mp3'
-o -iname '*.ogg' | sort >> $CTRL/list
draw
case /clear
echo clear > $CTRL/ctl
draw
case /save/*
cat $CTRL/list > lists/`{ echo $PATH_INFO | sed 's:^/save/::'}
draw
case /load/*
echo clear > $CTRL/ctl
cat lists/`{ echo $PATH_INFO | sed 's:^/load/::'} > $CTRL/list
draw
case /skip
echo skip > $CTRL/ctl
draw
case /skip/*
echo skip `{ echo $PATH_INFO | sed 's:^/skip/::'} > $CTRL/ctl
draw
case /jump/*
echo jump `{ echo $PATH_INFO | sed 's:^/jump/::'} > $CTRL/ctl
echo play > $CTRL/ctl
draw
case *
dunno
}
--
You received this message because you are subscribed to the Google Groups
"werc" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/werc9?hl=en.