在 Freeswitch 中停止播放
Stop a playback in Freeswitch
我在 Lua 中有一些代码可以接听电话,并在执行一系列操作后将电话桥接到新的支路。
操作需要几秒到几分钟。
为了保持客户端我需要播放声音我遇到的问题是呼叫桥接后播放仍在继续。
具体问题是,如何停止播放中调用的声音?
我的代码看起来像
session:answer()
session:execute("playback", '/some/file.wav')
.
.
.
local connectionString = '{bypass_media=true,origination_caller_id_number=555,destination_number=646}'
connectionString = connectionString .. 'sofia/external/192.168.0.1@1000'
session:execute('bridge', connectionString)
我有一个类似的任务,并通过为出站段启动一个新脚本来解决它。当出站支路得到应答时,我将 uuid_break
发送到入站支路,并让通道桥接在一起。它是在 Perl 中完成的,但是 Lua 应该非常相似:https://github.com/xlab1/freeswitch_secretary_bug(脚本在脚本目录中)。
来自the mod_commands
documentation:
uuid_break
Break out of media being sent to a channel. For example, if an audio
file is being played to a channel, issuing uuid_break
will
discontinue the media and the call will move on in the dialplan,
script, or whatever is controlling the call.
Usage: uuid_break <uuid> [all]
If the all
flag is used then all audio files/prompts/etc. that are
queued up to be played to the channel will be stopped and removed from
the queue, otherwise only the currently playing media will be stopped.
但一般来说,通过 ESL 实现此类场景要容易得多:您的程序可以通过 ESL 异步处理多个通道,并轻松执行所有需要的播放和中断。这里我用Golang做了一个简单的原型,通过ESL实现类似的场景:https://github.com/xlab1/go-fs-secretary-prototype(这里我使用了同步出站ESL套接字,但异步入站模式实现起来应该也不会太难)。
希望对您有所帮助:)
我在 Lua 中有一些代码可以接听电话,并在执行一系列操作后将电话桥接到新的支路。
操作需要几秒到几分钟。
为了保持客户端我需要播放声音我遇到的问题是呼叫桥接后播放仍在继续。
具体问题是,如何停止播放中调用的声音?
我的代码看起来像
session:answer()
session:execute("playback", '/some/file.wav')
.
.
.
local connectionString = '{bypass_media=true,origination_caller_id_number=555,destination_number=646}'
connectionString = connectionString .. 'sofia/external/192.168.0.1@1000'
session:execute('bridge', connectionString)
我有一个类似的任务,并通过为出站段启动一个新脚本来解决它。当出站支路得到应答时,我将 uuid_break
发送到入站支路,并让通道桥接在一起。它是在 Perl 中完成的,但是 Lua 应该非常相似:https://github.com/xlab1/freeswitch_secretary_bug(脚本在脚本目录中)。
来自the mod_commands
documentation:
uuid_break
Break out of media being sent to a channel. For example, if an audio file is being played to a channel, issuing
uuid_break
will discontinue the media and the call will move on in the dialplan, script, or whatever is controlling the call.Usage:
uuid_break <uuid> [all]
If the
all
flag is used then all audio files/prompts/etc. that are queued up to be played to the channel will be stopped and removed from the queue, otherwise only the currently playing media will be stopped.
但一般来说,通过 ESL 实现此类场景要容易得多:您的程序可以通过 ESL 异步处理多个通道,并轻松执行所有需要的播放和中断。这里我用Golang做了一个简单的原型,通过ESL实现类似的场景:https://github.com/xlab1/go-fs-secretary-prototype(这里我使用了同步出站ESL套接字,但异步入站模式实现起来应该也不会太难)。
希望对您有所帮助:)