1

我可以使用以下方式将多个文件一起流式传输:

$AGI->exec('Background',"file1&file2&file3&file4")

但是,这不会返回播放文件时用户按下的键。所以,我使用$AGI->stream_file了 ,它返回按下的键,但只播放一个文件。

我需要能够一起播放多个文件,播放应该在用户按下一个键的那一刻停止,我应该知道按下了哪个键。

我如何实现这一目标?

4

2 回答 2

3

这应该有效:

my $keyPress;
# fill in your filenames as appropriate...
foreach my $file (qw(file1 file2 file3))
{
    $keyPress = $AGI->stream_file($file);
    last if $keyPress;
}

# by this point, $keyPress will contain what key was pressed,
# 0 if all files played to completion, or -1 if a hangup occurred
# (as per the documentation).

您可以稍微缩短代码(例如将循环收紧为 do/while),但这种方式非常易读。

于 2009-08-24T17:03:25.410 回答
0

The Background command waits for the user to enter an extension and automatically sends them there, or to the i extension if it doesn't exist.

Use the Read command instead; Read will store whatever the user keys into a variable:

Read(SomeVar,file1,10); Read max 10 digits into SomeVar SayDigits(${SomeVar})

I think Asterisk now supports the file1&file2 stuff in the Read command but I don't know since what version it works that way.

于 2009-08-26T21:29:13.620 回答