Alexander Perkins
2019-May-15 02:29 UTC
[asterisk-users] Play Music While Processing AGI Script
Hi All. I have a question - I have an AGI script that may run for 10 seconds, or it may run for 60 seconds while an agent becomes available (agents are geographically dispersed). Is there a way to have the music play in the background while the AGI scripts executes? When the AGI script finishes, then the music should also finish. I tried this, but the music needs to finish before moving on to step 4 and execute the script. exten => _NXZNXXXXXX,1,Answer() exten => _NXZNXXXXXX,2,MusicOnHold() exten => _NXZNXXXXXX,3,AGI(SetRecordingID.php,${UNIQUEID}) Any help would be appreciated. Alex -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20190514/ed1e1865/attachment.html>
Steve Edwards
2019-May-15 04:32 UTC
[asterisk-users] Play Music While Processing AGI Script
On Tue, 14 May 2019, Alexander Perkins wrote:> Hi All. I have a question - I have an AGI script that may run for 10 seconds, or it may run for 60 seconds while an agent becomes available (agents are geographically > dispersed). Is there a way to have the music play in the background while the AGI scripts executes? When the AGI script finishes, then the music should also finish. > I tried this, but the music needs to finish before moving on to step 4 and execute the script. > > exten => _NXZNXXXXXX,1,Answer() > exten => _NXZNXXXXXX,2,MusicOnHold() > exten => _NXZNXXXXXX,3,AGI(SetRecordingID.php,${UNIQUEID})Create a separate thread in your AGI to play a small segment (5 to 10 seconds) of music in a loop. At the end of each 'play' check to see if the AGI is ready to exit. Off topic, but you can make maintenance of your dialplan easier if you write it like: exten = _nxznxxxxxx,1, answer() same = n, musiconhold() same = n, agi(SetRecordingID.php,${UNIQUEID}) The 'whitespace' and 'lowcasing' is just my personal preference. I would also use 'getopt/longopts' to parse the command line so you can have meaningful (long) options and are not dependent upon passing arguments in a particular order. -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST https://www.linkedin.com/in/steve-edwards-4244281