System information

The Playback() application is used for playing a previously recorded sound file over a
channel. Input from the user is ignored, which means that you would not use Play
back() in an auto attendant, for example, unless you did not want to accept input at
that point.
Asterisk comes with many professionally recorded sound files, which
should be found in the default sounds directory (usually /var/lib/aster-
isk/sounds/). When you compile Asterisk, you can choose to install
various sets of sample sounds that have been recorded in a variety of
languages and file formats. We’ll be using these files in many of our
examples. Several of the files in our examples come from the Extra
Sound Package, so please take the time to install it (see Chapter 3). You
can also have your own sound prompts recorded in the same voices as
the stock prompts by visiting http://www.theivrvoice.com/. Later in the
book we’ll talk more about how you can use a telephone and the dialplan
to create and manage your own system recordings.
To use Playback(), specify a filename (without a file extension) as the argument. For
example, Playback(filename) would play the sound file called filename.wav, assuming
it was located in the default sounds directory. Note that you can include the full path
to the file if you want, like this:
Playback(/home/john/sounds/filename)
The previous example would play filename.wav from the /home/john/sounds/ directory.
You can also use relative paths from the Asterisk sounds directory, as follows:
Playback(custom/filename)
This example would play filename.wav from the custom/ subdirectory of the default
sounds directory (probably /var/lib/asterisk/sounds/custom/filename.wav). Note that if
the specified directory contains more than one file with that filename but with different
file extensions, Asterisk automatically plays the best file.
#
The Hangup() application does exactly as its name implies: it hangs up the active chan-
nel. You should use this application at the end of a context when you want to end the
current call, to ensure that callers don’t continue on in the dialplan in a way you might
not have anticipated. The Hangup() application does not require any arguments, but
you can pass an ISDN cause code if you want (e.g., Hangup(16)).
There is another application called Background() that is very similar to Playback(), except that it does allow
input from the caller. You can read more about this application in Chapter 15 and Chapter 17.
#Asterisk selects the best file based on translation cost—that is, it selects the file that is the least CPU-intensive
to convert to its native audio format. When you start Asterisk, it calculates the translation costs between the
different audio formats (they often vary from system to system). You can see these translation costs by typing
show translation at the Asterisk command-line interface. The numbers shown represent how many
milliseconds it takes Asterisk to transcode one second of audio. We’ll talk more about the different audio
formats (known as codecs) in “Codecs” on page 625.
114 | Chapter 6:Dialplan Basics