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 Asterisk cmd 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 cmd Milliwatt: Generate a Constant 1004 Hz tone at 0dbm
- 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