blob: 0eabc9d9b9d2a849cba64791b0503e8117ef3c3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/bin/rc
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 {
if(~ $#* 0){
tmp=/tmp/play.$pid.tmp
dd -bs 64 -count 1 >$tmp >[2]/dev/null
cat $tmp /fd/0 | play1 `{file -m $tmp} xxx
cleanup
}
if not {
switch($1){
case *plain*
sed 's/
//g' | while(j=`{read}){
echo $"j >[1=2]
t=$typ
if(~ $"j http:* https:* HTTP:* HTTPS:*){
if(~ $#t 0) t=mp3
hget -r 'Icy-MetaData: 0' $j | play1 $t
}
if not {
if(test -r $"j){
if(~ $#t 0 && ~ $"j *mp3*) t=mp3
play1 $t <$"j
}
if not {
echo $argv0: 'can''t open file:' $"j >[1=2]
}
}
}
case *ogg* *vorbis*
audio/oggdec
case *mp3* *mpeg*
audio/mp3dec
case *flac*
audio/flacdec
case *pls*
awk 'BEGIN {FS="="} /^File/{print $2}' | play1 plain
case *
echo $argv0: unknown format: $1 >[1=2]
}
}
}
fn usage {
echo usage: $argv0 [ -t type ] [-o file ] [ file ... ] >[1=2]
exit usage
}
while(~ $1 -*){
switch($1){
case -t
typ=$2
shift
case -o
out=$2
shift
case *
usage
}
shift
}
>$out {
if(~ $#* 0){play1 $typ; exit}
for(i){echo $i} | play1 plain
}
|