mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Add streamfile.lua to provide ability to stream files and change the volume, position of the playback, pause and more.
This commit is contained in:
37
resources/install/scripts/streamfile.lua
Normal file
37
resources/install/scripts/streamfile.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
--get the argv values
|
||||
script_name = argv[0];
|
||||
file_name = argv[1];
|
||||
|
||||
--define the on_dtmf call back function
|
||||
function on_dtmf(s, type, obj, arg)
|
||||
if (type == "dtmf") then
|
||||
freeswitch.console_log("info", "[streamfile] dtmf digit: " .. obj['digit'] .. ", duration: " .. obj['duration'] .. "\n");
|
||||
if (obj['digit'] == "*") then
|
||||
return false; --end playback
|
||||
elseif (obj['digit'] == "0") then
|
||||
return("restart"); --start over
|
||||
elseif (obj['digit'] == "1") then
|
||||
return("volume:-1"); --volume down
|
||||
elseif (obj['digit'] == "3") then
|
||||
return("volume:+1"); -- volume up
|
||||
elseif (obj['digit'] == "4") then
|
||||
return("seek:-5000"); -- back
|
||||
elseif (obj['digit'] == "5") then
|
||||
return("pause"); -- pause toggle
|
||||
elseif (obj['digit'] == "6") then
|
||||
return("seek:+5000"); -- forward
|
||||
elseif (obj['digit'] == "7") then
|
||||
return("speed:-1"); -- increase playback
|
||||
elseif (obj['digit'] == "9") then
|
||||
return("speed:+1"); -- decrease playback
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--stream the file
|
||||
session:answer();
|
||||
if (session:ready()) then
|
||||
session:sleep(1000);
|
||||
session:setInputCallback("on_dtmf", "");
|
||||
session:streamFile(file_name);
|
||||
end
|
||||
Reference in New Issue
Block a user