Hey Adriano,

Yes, the code I shared is showing how to receive a call and respond with
audio.

I have a scenario where we allow users to initiate a call to themselves (by
pressing a button in a Web App) and when they pick up the call, we stream a
couple of audio files (one after the other) to give them instructions for
the system they are using. In our scenario though, we are just initiating
the call through the use of Call Files (
https://wiki.asterisk.org/wiki/display/AST/Asterisk+Call+Files). When the
user picks up, they just drop into the context specified in the Call File
which directs them to our Asterisk Java AgiScript. In this case, I still
use `getData` on the `AgiChannel` to stream the files when I need DTMF,
otherwise I just use the `exec` method on the AgiChannel to use the
Playback application within Asterisk.

If you are going to originate the Call in some other way, I won't be of
much help at the moment as I have not worked with the Asterisk Manager
Interface, (
https://wiki.asterisk.org/wiki/display/AST/The+Asterisk+Manager+TCP+IP+API)
yet. Asterisk Java does also support the Manager Interface so you might
find something that more closely resembles what you are looking to do at
http://asterisk-java.org .

On Fri, Nov 23, 2018 at 3:21 PM adriano santos <[email protected]> wrote:

> Hi  Brandon! Thank you for your response.
>
> Is the example you sent to receive a call and respond with correct audio?
> What I need to do is originate a call to cell phone and play audio. For
> now no need for DTMF.
>
> Regards,
> Adriano Santos
>
> Em sex, 23 de nov de 2018 às 18:34, Brandon Haugen <[email protected]>
> escreveu:
>
>> Hey Adriano,
>>
>> I have within the last few months started using Asterisk-Java for a
>> project and you can certainly playback an audio file. There are a couple of
>> things that you will have to think about to determine the best approach for
>> your situation, here is what I can tell you though
>>
>>    - If you do *not* need to listen for DTMF input (keypresses) while
>>    playing the audio file then you can play an audio file on an AgiChannel in
>>    Java by using something like `agiChannel.exec("playback", "<path to audio
>>    file>");`
>>       - This example in the Asterisk Java GitHub repository shows
>>       answering a call, playing a file back, and then hanging up (note that 
>> in
>>       the example they rely on methods defined in the AgiOperations class so 
>> they
>>       aren't operating directly on the AgiChannel like the line of code I am
>>       sharing is doing)
>>       
>> https://github.com/asterisk-java/asterisk-java/blob/master/src/main/java/org/asteriskjava/examples/fastagi/ExampleCallIn.java
>>    - If you *do* need to listen for DTMF input while playing the audio
>>    file then you will want to use the `getData` or `getOption` methods 
>> defined
>>    on AgiChannel. You will need to pick which method is appropriate depending
>>    on the length of DTMF you need to listen for (`getOption` returns a single
>>    char while `getData` will return a String)
>>
>> Thanks,
>> Brandon
>>
>> On Thu, Nov 22, 2018 at 12:09 PM adriano santos <[email protected]>
>> wrote:
>>
>>> Hello, guys!
>>>
>>> I would like to play an audio file on a initialized call via java. I
>>> haven't found an example for this.
>>> Is this possible?
>>>
>>> --
>>> Adriano P. Santos
>>>
>>> "O homem erudito é um descobridor de fatos que já existem - mas o homem
>>> sábio é um criador de valores que não existem e que ele faz existir."
>>> Albert Einstein
>>> _______________________________________________
>>> Asterisk-java-users mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>>
>> _______________________________________________
>> Asterisk-java-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>>
>
>
> --
> Adriano P. Santos
>
> "O homem erudito é um descobridor de fatos que já existem - mas o homem
> sábio é um criador de valores que não existem e que ele faz existir."
> Albert Einstein
> _______________________________________________
> Asterisk-java-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
_______________________________________________
Asterisk-java-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users

Reply via email to