login | register
Sat 04 of Jul, 2009 [12:35 UTC]

voip-info.org

History

Asterisk cmd Playback

Created by: oej,Last modification on Wed 10 of Jun, 2009 [15:58 UTC] by mathieuparent

Synopsis

Play a sound and/or video file


Description

 Playback(filename1[&filename2...][,options])

Plays the specified sound or video file(s) (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(s), 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.

j: If option is specified, the application will jump to priority n+101 if present when a file specified to be played does not exist.

say: Use say.conf to interpret the string

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

On completion, ${PLAYBACKSTATUS} contains either "FAILED" or "SUCCESS".

Troubleshooting

Playback is not affected by timing, unless internal_timing is turned on in asterisk.conf.

See also



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


Comments

Comments Filter
222

333Relative path

by Ayth, Friday 16 of January, 2009 [18:08:20 UTC]
Interestingly enough, I discovered through testing that relative paths work in Playback, and Background. For example,

Say you have a sound file called soundfile.wav, located in /var/lib/asterisk/sounds/custom/.

You can actually shorten the command as so

exten => s,1,NoOp()
exten => s,n,Answer
exten => s,n,Playback(./custom/soundfile)
exten => s,n,Hangup

Just thought to add this.
222

333Playback with music background (MOH) support

by mesfet, Tuesday 30 of September, 2008 [05:50:04 UTC]
I believe that an interesting thing (that now is not supported) is the possibility to play a sound file using the music-on-hold as a background: in this way messages should be played nicely.

exten => s,n,Playback(instructions|m) ;play instruction message, with music background

The same thing should be done for Background application.
I don't know if it's easy or not to do this, hope that a similar feature should be implemented.
Best regards. Paolo
222

333examples to show support for multiple sound files

by baji, Friday 04 of July, 2008 [23:09:12 UTC]
.
.
The most important feature of playback, imho, is its flexibility for playing multiple sound files separated by "&".

exten => s,n,Playback(file1&file2&file3&....)

Spaces around "&" are not tolerated, they are recognized as a part of the filename and asterisk will log a "file not found in any format" error.

You can also use variable names mixed in with literal names for filenames, for eg.

exten => s,n,Playback(${var_file1}&literal_file2&literal_file3&${var_file4}&....)

You can also use variables for parts of a file name, eg.

exten => s,n,Set(MyLang=english)
exten => s,n,Playback(for-${MyLang}-press)

Playback CANNOT be INTERRUPTED with touch tone input, for interruptible audio use Read() or Background(). But Read DOES NOT play multiple sounds files.

The sound filenames in playback can be names in the asterisk sounds dir OR they can be absolute path names.

Playback easily accommodates several hundred chars long filenames string. Eg.

exten => s,n,Playback(/var/lib/asterisk/sounds/what-time-it-is&/var/lib/asterisk/sounds/freezing)

The full paths were not needed in the above example because we were referring to files in the asterisk sounds dir.

Another example illustrating the flexibility of Playback filenames support -

exten => s,n,Set(Files2Play=$The attachment id given is not valid.&$The attachment id given is not valid.)
exten => s,n,Set(Files2Play=${Files2Play}&file_3&file_4)
exten => s,n,Playback(${Files2Play})

222

333can jump to priority n+101

by effriti, Thursday 13 of April, 2006 [14:33:34 UTC]
There's also the option j.
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)