I want to play music in my agi while i am searching for a field in DB. Actually during some processes in AGI i need to play music . Thanks in advanced.
Do your query really takes “so” long? You should consider to use to optimize your database or query instead.
OR take a look at AsncAGI:
Am 26.09.2012 11:35, schrieb Mehdi Rahimi:
+1 – if your query is going to take long enough that you need to play music, you need to optimize the process somewhere. FWIW, if you do play music, you will need to “fork” the process as the music process is not asynchronous.
Many moons ago, I had a client that wanted ‘instantaneous’ response to a credit card authorization request. (The request could take a couple of seconds because it involved an external vendor.)
My solution was an AGI that played a prompt (‘Please wait while your card is being processed and get ready for a good time’) in one thread while the
‘mainline’ code processed the auth. By the time the prompt finished, I had the auth response and the ‘experience’ was that the auth was instantaneous.
One of the ‘gotchas’ is that you can’t do any ‘AGI’ stuff in the mainline code while the background thread is playing the prompt — which is kind of obvious if you understand the AGI protocol.
Another option to consider is the externalivr() application.
Probably Local channels to the rescue here.
Dear Leif Madsen,
Please explain more
It’s been quite some time since I did this, so I can’t give you a specific example (that’s left as an exercise to the reader), and I may be misremembering, but essentially I had 2 Local channels that I
“called” via the Dial() application. One path played MusicOnHold() and the other would perform some fancy stuff (I think it was an API call via CURL() that would attempt to return a valid agent; a sort of dialplan based queuing system that used an external API interface that managed the availability of the agents).
Anyways, the one Local channel would play MusicOnHold(), then when the API returns data to CURL(), the dialplan would continue and pull the caller out of the MusicOnHold() application, and then send them to the dialplan section to call the agent.
The same principles could be applied here. I think it was a combination of MusicOnHold(), Local channels, and the Bridge() application.
Sometimes you just have to be really clever with Asterisk to make it do what you want 🙂
A multi-threaded AGI or externalivr() sound easier to me if it meets your needs.