2012-01-22 22:30:34 +00:00
|
|
|
#!/bin/rc
|
2012-05-26 19:18:41 +00:00
|
|
|
rfork e
|
2012-01-22 22:30:34 +00:00
|
|
|
|
|
|
|
out=/dev/audio
|
|
|
|
typ=()
|
|
|
|
tmp=()
|
|
|
|
argv0=$0
|
|
|
|
|
|
|
|
fn cleanup {
|
|
|
|
if(! ~ $#tmp 0)
|
|
|
|
rm -f $tmp
|
|
|
|
tmp=()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn sigint {
|
|
|
|
cleanup
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
fn sigexit {
|
|
|
|
cleanup
|
|
|
|
}
|
|
|
|
|
|
|
|
fn play1 {
|
2013-10-29 23:09:27 +00:00
|
|
|
if(! ~ $#* 2){
|
2012-02-14 16:29:18 +00:00
|
|
|
tmp=(/tmp/play.$pid.$#tmp.tmp $tmp)
|
2012-02-19 18:45:13 +00:00
|
|
|
dd -bs 8192 -count 1 >$tmp(1) >[2]/dev/null
|
2013-10-29 23:09:27 +00:00
|
|
|
cat $tmp(1) /fd/0 | play1 $1 `{file -m $tmp(1)}
|
2012-01-22 22:30:34 +00:00
|
|
|
cleanup
|
|
|
|
}
|
|
|
|
if not {
|
2013-10-29 23:09:27 +00:00
|
|
|
switch($2){
|
2012-01-22 22:30:34 +00:00
|
|
|
case *plain*
|
|
|
|
sed 's/
//g' | while(j=`{read}){
|
2012-01-22 00:12:28 +00:00
|
|
|
echo $"j >[1=2]
|
2012-01-22 22:30:34 +00:00
|
|
|
if(~ $"j http:* https:* HTTP:* HTTPS:*){
|
2014-05-13 23:15:33 +00:00
|
|
|
hget -r 'User-Agent: play' -r 'Icy-MetaData: 0' $"j | play1 $"j
|
2012-01-22 22:30:34 +00:00
|
|
|
}
|
|
|
|
if not {
|
2012-02-14 16:29:18 +00:00
|
|
|
if(test -r $"j)
|
2013-10-29 23:09:27 +00:00
|
|
|
play1 <$"j $"j
|
2012-01-22 00:12:28 +00:00
|
|
|
if not {
|
|
|
|
echo $argv0: 'can''t open file:' $"j >[1=2]
|
2012-01-22 22:30:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case *ogg* *vorbis*
|
|
|
|
audio/oggdec
|
|
|
|
case *mp3* *mpeg*
|
|
|
|
audio/mp3dec
|
2012-03-08 06:25:14 +00:00
|
|
|
case *wave*
|
|
|
|
audio/wavdec
|
2012-02-11 07:33:22 +00:00
|
|
|
case *flac*
|
|
|
|
audio/flacdec
|
2012-12-14 04:00:51 +00:00
|
|
|
case *audio/basic*
|
|
|
|
audio/sundec
|
2012-01-22 22:30:34 +00:00
|
|
|
case *pls*
|
2013-10-29 23:09:27 +00:00
|
|
|
awk 'BEGIN {FS="="} /^File/{print $2}' | play1 list plain
|
2012-01-22 22:30:34 +00:00
|
|
|
case *
|
2013-10-29 23:09:27 +00:00
|
|
|
switch($1){
|
|
|
|
case *.mp3 *.MP3
|
|
|
|
audio/mp3dec
|
|
|
|
case *.ogg *.OGG
|
|
|
|
audio/oggdec
|
|
|
|
case *.wav *.WAV
|
|
|
|
audio/wavdec
|
|
|
|
case *.flac *.FLAC
|
|
|
|
audio/flacdec
|
|
|
|
case *.au *.AU
|
|
|
|
audio/sundec
|
|
|
|
case *
|
|
|
|
echo $argv0: $1: unknown format: $2 >[1=2]
|
|
|
|
}
|
2012-01-22 22:30:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn usage {
|
2012-02-14 16:29:18 +00:00
|
|
|
echo usage: $argv0 [ -o file ] [ file ... ] >[1=2]
|
2012-01-22 22:30:34 +00:00
|
|
|
exit usage
|
|
|
|
}
|
|
|
|
|
|
|
|
while(~ $1 -*){
|
|
|
|
switch($1){
|
|
|
|
case -o
|
|
|
|
out=$2
|
|
|
|
shift
|
|
|
|
case *
|
|
|
|
usage
|
|
|
|
}
|
|
|
|
shift
|
|
|
|
}
|
|
|
|
|
2012-05-08 10:39:30 +00:00
|
|
|
# boost priority
|
|
|
|
@{echo pri 13 >/proc/$pid/ctl} >/dev/null >[2=1]
|
|
|
|
|
2012-01-22 22:30:34 +00:00
|
|
|
>$out {
|
2013-10-29 23:09:27 +00:00
|
|
|
if(~ $#* 0){play1 stdin; exit}
|
|
|
|
for(i){echo $i} | play1 args plain
|
2012-01-22 22:30:34 +00:00
|
|
|
}
|