From 49fa3172980f1a22e51799ed3d93235e878e2838 Mon Sep 17 00:00:00 2001 From: Brian West Date: Mon, 6 Mar 2006 18:55:28 +0000 Subject: [PATCH] Start the documents on mod_spidermonkey. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@764 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- docs/JavaScript.txt | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 docs/JavaScript.txt diff --git a/docs/JavaScript.txt b/docs/JavaScript.txt new file mode 100644 index 0000000000..ac5a3e4085 --- /dev/null +++ b/docs/JavaScript.txt @@ -0,0 +1,48 @@ +Session Methods +======================================= + +session.streamFile + +Usage: + +session.streamFile(file, timer, callback); + + file = Path to the file to play (ie /tmp/file.wav) + timer = Timer to use for async mode. (optional) + callback = Which function to fire when a dtmf digit is pressed. (optional) + +Callback return values and meanings: + + seek:ms - +1000 or -1000 will seek 1000ms forward or backwards, seek 0 will start the file over. + speed: - +1,-1 or 0 for normal speed. (valid ranges are +1,+2, 0 or -1,-2) + pause: - toggles pause and play modes on the file. + + You can also return arbitrary values and act on them as you + wish. In our example we return "hangup" when the caller + press the * key on the keypad. + + +Example: + +function on_dtmf(digits) +{ + if (digits == "3") { + return "seek:+1000"; + } + if (digits == "1") { + return "seek:-1000"; + } + if (digits == "*") { + return "hangup"; + } +} + +session.answer(); + +while(session.state == "CS_EXECUTE") { + allDigits = ""; + return_value = session.streamFile("/tmp/demo.wav", "", "on_dtmf"); + if (return_value == "hangup") { + session.hangup(); // or break; + } +}