Common Issues

Music on Hold/MP3 Playback

Before using Asterisk's Music On Hold feature, mpg123 and a timing system must be in place.

Proper Version of MPG123

Music on Hold requires mpg123. Note that mpg321, which is often linked to /usr/bin/mpg123, will not work. Additionally, mpg123 must be installed in /usr/bin.

Note

The latest release of mpg123 is mpg123 0.59r. The latest development release of mpg123 is mpg123 pre0.59s. Please use mpg123 0.59r. Using mpg123 pre0.59s can/may/will result in crashes and/or unreliable playback.

mpg123 can be downloaded from http://www.mpg123.de. Before compiling mpg123, change the line in the Makefile that reads


				PREFIX=/usr/local
			
to

				PREFIX=/usr
			
After making the change, mpg123 can be compiled as described in its documentation.

Timing: zaptel/ztdummy/zaprtc

Asterisk's Music On Hold application requires a timing source to work correctly. There are three possible timing sources that can be used:

Zaptel

The Zaptel drivers, which run Digium's Wildcard cards, can be used as a timing source. If you have a Zaptel card, there is no special setup needed other than loading the standard kernel module for the card. Simply set up the Zaptel interface as described previously in this guide.

ztdummy

ztdummy is a Zaptel driver designed for use as a timing source without having a Wildcard board. It uses the USB devices for timing, so the usb-ohci kernel module must be installed (lsmod can be used to check). ztdummy is included with the zaptel tree of Asterisk CVS. By default, however, it is not compiled. To enable the compilation of ztdummy, open the Makefile in zaptel source directory for editing. Find the line that reads


					MODULES=zaptel.o tor2.o torisa.o wcusb.o wcfxo.o wcfxs.o \
					        ztdynamic.o ztd-eth.o wct1xxp.o wct4xxp.o # ztdummy.o
				
and remove the # before 'ztdummy.o'. From there, run make and make install as usual. Before running Asterisk, you'll need to load the ztdummy driver by running modprobe ztdummy.

zaprtc

ztrtc uses the system clock rather than the USB subsystem to get timing information. Note, however, that ztrtc does not work on multiprocessor systems. ztrtc does not come with Asterisk but is available from http://www.junghanns.net/asterisk/.

Configuration File: /etc/asterisk/musiconhold.conf

The musiconhold.conf syntax is simple and similar to other Asterisk files. Here is a sample configuration file:


				[classes]
				default => quietmp3:/var/lib/asterisk/mohmp3
				nirvana => quietmp3:/usr/share/mp3/nirvana-music
				random-nirvana => quietmp3:/usr/share/mp3/nirvana-music,-z
				loud-nirvana => mp3:/usr/share/mp3/nirvana-music
			
In this example, the class default plays MP3s from the directory /var/lib/asterisk/mohmp3/ sequentially. Note the 'quietmp3' directive, which keeps the music at an appropriate volume for most telephony Music on Hold applications. The class nirvana is similar, but uses the directory /usr/share/mp3/nirvana-music/ instead. random-nirvana picks files in the directory randomly, instead of sequentially, due to the '-z' option at the end of the line. The final class, loud-nirvana does not reduce the volume of the output, due to 'quietmp3' being replaced by 'mp3'. The 'mp3' directive is useful for applications targeting the hearing impaired (as well as Nirvana fans).

Adding Music on Hold to the Dialplan

Adding Music on Hold to the dial plan is fairly straightforward and simple. Just add MusicOnHold(class) as you would Dial() or Voicemail(). For example:


				exten => 6789,1,Answer()
				exten => 6789,2,MusicOnHold(nirvana)
			

A Final Note on Choosing Music

In the United States and other countries, playing copyrighted music to strangers who call into your PBX (without a proper license) is illegal. However, high-quality, royalty free music does exist. An excellent source for it is http://www.openmusicregistry.org.

Licensing music from well-known artists is not terribly expensive, however. For sites with 10 or fewer incoming telco lines, a license from BMI (the largest licensor of popular music) can be had for a little less than $200 per annum. With this license, you may use any of BMI's 4.4 million songs for a Music on Hold application. More details are available at http://www.bmi.com.