Java 如何在asterisk中为被叫方播放声音

Java 如何在asterisk中为被叫方播放声音,java,asterisk,fastagi,Java,Asterisk,Fastagi,用于拨打我正在使用的号码 exec("DIAL", "DAHDI/g0/" + callingPhoneNo + "," + currentTimeOut + ",mg,"); 在我的java应用程序中。 以及使用此代码段为调用者播放声音: exec("background", "custom/incorrectPassword"); 但是,我怎样才能在拔出电话后为呼叫接收器播放声音呢?如中所述:有一个选项就可以了。 意味着在这种情况下,使用 exec("DIAL", "DAHDI/g0/"

用于拨打我正在使用的号码

exec("DIAL", "DAHDI/g0/" + callingPhoneNo + "," + currentTimeOut + ",mg,");
在我的java应用程序中。 以及使用此代码段为调用者播放声音:

exec("background", "custom/incorrectPassword");
但是,我怎样才能在拔出电话后为呼叫接收器播放声音呢?

如中所述:有一个选项就可以了。 意味着在这种情况下,使用

exec("DIAL", "DAHDI/g0/" + callingPhoneNo + "," + currentTimeOut + ",mg|A(custom/greet)");

命令,在拿起电话后为被叫人播放问候文件。

您还可以在拨号应用程序中使用特殊分机(宏)。这是在被叫人拿起电话后运行的。也可以在其中传递参数

示例2:拨号宏

执行此操作有3个选项。实际上只需要一个选项,但历史上我们有3个

1) 正是出于此目的,在Dial命令diallout parameters中选择A

A(x):
x-要播放给被叫方的文件
向被叫方播放公告,提示在哪里
待玩
2) 隐私模式选项

p:此选项启用筛选模式。这基本上是隐私 没有内存的模式

P([x]):启用隐私模式。用作AstDB中的族/键
数据库(如果提供)。如果是数据库,则使用当前扩展名
未指定族/键。
基于callerid的隐私播放消息,如果找不到则询问姓名

3) 宏和Gosub的答案。只是不同的和最灵活的方式来处理调用,使用它您可以收集输入/确认/拒绝调用等

M(宏[^arg[^…]):

macro—应执行的宏的名称。
arg-宏参数
执行之前为*被调用*通道指定的
正在连接到呼叫频道。可以为宏指定参数
使用“^”作为分隔符。宏可以设置变量${macro\u RESULT}
要在宏完成执行后指定以下操作:
${MACRO_RESULT}:如果已设置,则此操作将在
宏已完成执行。
中止:挂断呼叫的两个分支
拥塞:表现得好像线路拥塞是正常的
遇到
忙:表现为遇到忙信号
继续:挂断被叫方并允许
呼叫方以下一优先级继续拨号计划执行
转到:[[^]^]:转移
调用指定的目标。
U(x[^arg[^…]):
x—通过Gosub执行的子例程的名称
arg-Gosub例程的参数
之前,通过Gosub执行*被调用*通道的例程
正在连接到呼叫频道。可以为Gosub指定参数
使用“^”作为分隔符。Gosub例程可以设置变量${GO
SUB_RESULT}指定Gosub返回后的以下操作。
${GOSUB_RESULT}:
中止:挂断呼叫的两个分支。
拥塞:表现得好像线路拥塞是正常的
遇到。
忙:表现为遇到忙信号。
继续:挂断被叫方并允许
呼叫方以下一优先级继续拨号计划执行。
转到:[[^]^]:转移
调用指定的目标。

我有同样的问题,尝试了你的代码,但它不适合我。它给出了“线程中的异常”main“java.lang.IllegalStateException:尝试从无效线程发送命令”,但如果该答案被标记,则应该可以工作。我想我不能使用exec命令,但我不确定。你能帮助我吗?
A(x): 
        x - The file to play to the called party
    Play an announcement to the called party, where <x> is the prompt
    to be played
P([x]): Enable privacy mode. Use <x> as the family/key in the AstDB
    database if it is provided. The current extension is used if a database
    family/key is not specified.
        macro - Name of the macro that should be executed.

        arg - Macro arguments

    Execute the specified <macro> for the *called* channel  before
    connecting to the calling channel. Arguments can be specified to the Macro
    using '^' as a delimiter. The macro can set the variable ${MACRO_RESULT}
    to specify the following actions after the macro is finished executing:

        ${MACRO_RESULT}: If set, this action will be taken after
        the macro finished executing.

            ABORT: Hangup both legs of the call

            CONGESTION: Behave as if line congestion was
            encountered

            BUSY: Behave as if a busy signal was encountered

            CONTINUE: Hangup the called party and allow the
            calling party to continue dialplan execution at the next priority

            GOTO:[[<context>^]<exten>^]<priority>: Transfer the
            call to the specified destination.




U(x[^arg[^...]]): 

    x - Name of the subroutine to execute via Gosub
    arg - Arguments for the Gosub routine

Execute via Gosub the routine <x> for the *called* channel before
connecting to the calling channel. Arguments can be specified to the Gosub
using '^' as a delimiter. The Gosub routine can set the variable ${GO
SUB_RESULT} to specify the following actions after the Gosub returns.

    ${GOSUB_RESULT}: 
        ABORT: Hangup both legs of the call.
        CONGESTION: Behave as if line congestion was
        encountered.
        BUSY: Behave as if a busy signal was encountered.
        CONTINUE: Hangup the called party and allow the
        calling party to continue dialplan execution at the next priority.
        GOTO:[[<context>^]<exten>^]<priority>: Transfer the
        call to the specified destination.