The Playback application

Asterisk is capable of much more than just routing calls. As you might guess, the Playback application is used to play a sound file (or even a video) over a channel.

Asterisk comes with a bunch of sound files that are stored in the /var/lib/asterisk/sounds directory by default. The Playback application requires only the single parameter to be specified – the name of the sound file (without the extension). You can also specify a full path to the sound file, which can be useful if a file exists in a different location than the default one.

One important thing to remember about this application is that it plays the whole sound file and ignores any input from the caller. This means that this application is not meant to be used in an auto attendant; the application called Background is used instead.

Let’s add the following code to our extensions.conf file:

exten => 999,1,Answer()
 same => n,Playback(this-call-may-be-monitored-or-recorded)
 same => n,Hangup()

The code above will play the this-call-may-be-monitored-or-recorded sound file from the /var/lib/asterisk/sounds/en directory. If you’ve followed along, you can try to dial 999 and you should hear a voice informing you that the call may be monitored or recorded.

 

Geek University 2022