[asterisk-users] Playback file and detect a key press

Moises Silva moises.silva at gmail.com
Sat Dec 8 13:40:45 CST 2007


Bob,

GET DATA should do something like that. But, to do "exactly" that, you
could try a patch I did to call AGI(agi:async), this is a special way
of AGI. As you know, you can already call AGI(name-of-script.php), or
AGI(agi://ipaddress) for the so named FastAGI. I created another
variant AGI(agi:async) that will allow you to run AGI thru the manager
interface. That way you could easily do this in a language like php.

agi_handler.php

/* AGI(agi:async) launch a manager event at start with all the init
data you get usually in a normal AGI (agi_request, agi_exten etc etc)
url-encoded. This function is called anytime that event is received */
function handle_AsyncAGI($data){
    $agi_data = urldecode($data);
     $my_manager->SendAction('AGI', array('Channel' =>
$agi_data['agi_channel'], 'Command' => 'EXEC Playback tt-monkeys',
'CommandID' => 'IDx'));
}

function handle_EndPlayback($data)
{
     // here you catch the end of the AGI EXEC playback command
executed and you know if DTMF was received on that channel
}

function OnDtmfEvent($data)
{
   // here you can see if the DTMF was received in some channel
executing playback
}


With this you get a lot of power, but also means you need to know how
to do async programming. The script of course, will needs to stay
connected to the manager in order to send the AGI commands and catch
the event responses.

You can find my patch back-ported to 1.4 here:

http://www.moythreads.com/asterisk-1.4.15-async-agi.patch

Also, you can follow the bug in
http://bugs.digium.com/view.php?id=11282 to see if it gets included in
Asterisk 1.6 ( not likely since I don't think Digium is accepting
features for 1.6 ) or a future release.

I will update that bug report with better documentation. Please not
that the original description in the bug does not suit anymore since
my initial patch was different.

Regards,

Moisés Silva

On Dec 8, 2007 12:05 AM, Bob Smither <Smither at c-c-i.com> wrote:
> I would like to do the following:
>
> Play back a file, and during the playback be able to detect a DTMF tone
> that may be pressed.  I do not want to interrupt the playing of the
> file, but when the file finishes I would like to be able to tell if a
> key was pressed and which key it was.
>
> Anyway to do this?
>
> In AGI:
>
> o  Wait for Digit waits for a digit to be pressed, and I don't see how
> to play a file at the same time.
> o  Stream File can detect a digit, but then the file playback is
> interrupted.
>
> In a call plan:
>
> o  Playback plays a file but does not detect pressed digits.
> o  Background plays a file, but stops the playback when a key is
> pressed.
>
> Is there anyway to do what I want to do?
>
> Thanks!
>
> --
> Bob Smither <Smither at C-C-I.com>
>
>
> _______________________________________________
> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users
>



-- 
"Within C++, there is a much smaller and cleaner language struggling
to get out."



More information about the asterisk-users mailing list