Synopsis
Play a sound fileDescription
Playback(filename,options...)Plays the specified sound file (you need to omit the filename extension). Sound files are stored in the /var/lib/asterisk/sounds directory by default (the directory path can be changed in asterisk.conf).
Playback is Multi-Language-compliant. It will look in a subdirectory corresponding with the current language code (as set by the SetLanguage command, or the channel's default language code. Failing that, it will play the non-language-specific edition.
Playback will play the whole sound file, and when complete, return control. Compare with the Background command, which plays a sound file but returns control immediately, allowing Asterisk to perform other commands on this channel while the sound file is playing.
Options
skip: Play the sound file only if the channel has already been answered. If the channel has not yet been answered, the Playback command will return immediately without playing anything.noanswer: Play the sound file, but don't answer the channel first (if hasn't been answered already). Not all channels support playing messages while still on hook.
If neither skip nor noanswer options are specified, then the Playback command will first answer the channel (if it hasn't been answered already) and then play the sound file.
Note: The options wont work if there are spaces between the filename, the comma and the option(s).
Example
exten => 500,1,Playback(tt-weasels,skip)Return Code
Returns -1 if the channel was hung up, or if the file does not exist. Returns 0 otherwise.On completion, ${PLAYBACKSTATUS} contains either "FAILED" or "SUCCESS".
See also
- ControlPlayback: Play a sound file with fast forward, rewind and exit controls
- Background: Play a sound file while processing other commands
- Playtones: Play a tone sequence
- Asterisk cmd Progress: Prepare to play early audio to the caller without answering the channel
- MP3Player: Play an MP3 sound file
- MusicOnHold
- Sound Files
- Asterisk tips answer-before-playback: Why you need to answer before sending sound on a channel
Asterisk | Configuration | The Dialplan - extensions.conf | Dialplan Commands
Page Changes
can jump to priority n+101
If the global option priorityjumping is enabled, or option "j" is passed to Playback, it will jump to priority n+101 if a file to be played doesn't exist.
Silly example:
(if 'file' doesn't exist, it will end up on priority 700)
(...)
priorityjumping=yes
(...)
exten => s,400,NoOp(lala)
exten => s,n,NoOp(var1: ${var1})
exten => s,n,Playback(file)
exten => s,n,Goto(600)
exten => s,500,Set(var2=x)
exten => s,n,GotoIf(test?600)
exten => s,n,Set(anothervar=)
exten => s,n,Goto(700)