Asterisk cmd Playtones
Created by: oej,Last modification on Mon 31 of Mar, 2008 [12:18 UTC] by JustRumours
Synopsis
Play a tone listDescription
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 playtonesexten => 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
- StopPlaytones
- Asterisk cmd Progress: Inband progress information (can be used without answering the line)
- Asterisk cmd Busy and Asterisk cmd Congestion
- DigitTimeout: Set allowable timeout between digits
- ResponseTimeout: Set allowable timeout between digits
- Background: Play a sound file while executing other commands
- Playback: Play a sound file
- ControlPlayback: Play a sound file with fast forward, rewind and exit controls
- WaitExten: Waits a given time and restarts the context with the entered digits
Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ

Comments
333use during call
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.
333Exclamation point in Playtones
The leading exclamation point in front of each play-item causes it not to be repeated.
333Example for playtones
- using the active country definition in indications.conf
-
exten => 223,1,Answerexten => 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