3 # Simple AGI application to play mp3's selected by a user both using
4 # xmms and over the phone itself.
9 last unless length($_);
10 if (/^agi_(\w+)\:\s+(.*)$/) {
15 print STDERR
"AGI Environment Dump:\n";
16 foreach $i (sort keys %AGI) {
17 print STDERR
" -- $i = $AGI{$i}\n";
20 dbmopen(%DIGITS, "/var/lib/asterisk/mp3list", 0644) || die("Unable to open mp3list");;
28 $res =~ /result=(-?[\w\*\#]+)/;
35 #print STDERR "1. Playing beep...\n";
36 #print "STREAM FILE beep \"\"\n";
38 #checkresult($result);
40 print STDERR
"2. Getting song name...\n";
41 print "GET DATA demo-enterkeywords\n";
43 $digitstr = checkresult
($result);
47 $digitstr =~ s/\*/ /g;
49 print STDERR
"Resulting songname is $digitstr\n";
50 @searchwords = split (/\s+/, $digitstr);
51 print STDERR
"Searchwords: " . join(':', @searchwords) . "\n";
53 foreach $key (sort keys %DIGITS) {
54 @words = split(/\s+/, $DIGITS{$key});
56 foreach $search (@searchwords) {
57 $match = 0 unless grep(/$search/, @words);
60 print STDERR
"File $key matches\n";
62 print "STREAM FILE beep \"\"\n";
65 if (&checkresult
($result) < 0) {
68 print "EXEC MP3Player \"$key\"\n";
69 # print "WAIT FOR DIGIT 60000\n";
71 if (&checkresult
($result) < 0) {
74 print STDERR
"Got here...\n";
78 print STDERR
"4. Testing 'saynumber' of $digitstr...\n";
79 print "STREAM FILE demo-nomatch\"\"\n";