login | register
Tue 07 of Oct, 2008 [18:29 UTC]

voip-info.org

Discuss [3] History

Asterisk cmd Playtones

Created by: oej,Last modification on Mon 31 of Mar, 2008 [12:18 UTC] by JustRumours

Synopsis

Play a tone list

Description

   Playtones(tonename)
   Playtones(tonelist)

Plays a tone list, either the tone named tonename defined in the indications.conf file, or a directly specified tonelist of frequencies and durations. See indications.conf for a description of the specification of a tonelist.

Execution will continue with the next step immediately, while the tones continue to play. Use StopPlaytones to stop the tones playing. In this way, it is similar to the Background command, which plays a given sound file "in the background".
A leading exclamation point in front of each play-item causes it not to be repeated.

Like Background, if Playtones is active when execution reaches the highest-priority command defined in for the extension, then the sound will continue to play until either the user dials an extension, or ResponseTimeout seconds passes, triggering Asterisk to jump to the 't' extension, if there is one defined in this context, or to the h extension (hangup) if there isn't.

Playing tones while dialling


If you want tones to play when Dial()ing, make sure to use the & Dial() syntax — otherwise tones will stop as soon as the Dial() command is reached. If you only have one channel to dial to, make a dummy one, like so:

  [dialout]
  exten => _X.,1,Answer()
  ; play tones to give the caller some feedback
  exten => _X.,n,Playtones(425/50,0/50)
  ; no-op here so that tones continue until we've actually reached the SIP peer
  exten => _X.,n,Dial(SIP/${EXTEN}@sip.example.com&Local/s@no-op)

  [no-op]
  ; just hang up
  exten => s,1,Hangup(21)

Examples

  ;testing playtones
  exten => 209,1,Answer
  exten => 209,2,Playtones(congestion)
  ; Tones will play until timeout or user dials a different extension

  exten => 264,1,Answer
  exten => 264,2,Wait(1)
  exten => 264,3,Playtones(!950/330,!1400/330,!1800/330,0)
  exten => 264,4,Wait(5)
  exten => 264,5,StopPlaytones
  exten => 264,6,Wait(2)
  exten => 264,7,Playback(beep)
  exten => 264,8,Hangup

Example 2

Especially useful for the s extension:
  exten => s,1,Answer
  exten => s,2,Playtones(dial)
  ;use DigitTimeout previous to Asterisk 1.2
  exten => s,3,Set(TIMEOUT(digit)=5)
  exten => s,4,WaitExten(60)

See also



Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ


Comments

Comments Filter
222

333use during call

by byo71, Thursday 18 of September, 2008 [10:16:37 UTC]
anyone know how to use this to inject the record tone every 20 seconds or so to indicate that the call is being recorded? specifically with the mixmonitor command

the indications.conf readme says " record = tonelist
; Set of tones played when call recording is in progress."

If I call the Playtones(record) before a Dial() it will play the beep until the call is answered, but then stop as soon as it gets picked up.

I would just like it to beep every 20 seconds during the conversation (i know it sounds annoying to me too, but that is what the client wants to happen)

I have been struggling with this for a few hours now.
222

333Exclamation point in Playtones

by aa84, Wednesday 19 of July, 2006 [18:04:50 UTC]
Ref: http://www.marko.net/asterisk/archives/0210/0420.html


The leading exclamation point in front of each play-item causes it not to be repeated.
222

333Example for playtones

by , Tuesday 02 of December, 2003 [13:25:09 UTC]
Make sure you add a Wait(x) as next priority after Playtones()! Examples:

using the active country definition in indications.conf
exten => 223,1,Answer
exten => 223,2,Wait(1)
exten => 223,3,Playtones(congestion)
exten => 223,4,Wait(5)
exten => 223,5,Hangup

; without the definitions in indications.conf
exten => 224,1,Answer
exten => 224,2,Wait(1)
exten => 224,3,Playtones(!950/330,!1400/330,!1800/330,0)
exten => 224,4,Wait(5)
exten => 224,5,Hangup