Streaming Music on Hold in Elastix 2.0

Elastix 2.0.3 is a Linux distribution that contains Asterisk 1.6.2.13 (as of the writing of this article) and other Asterisk centric addons, such as the Elastix web interface, Hylafax and Flash Operator Panel. Arguably, Elastix is the best Asterisk package available today and is an enterprise ready implementation of the Asterisk phone system software. Enough about my experience-driven opinion on Elastix and Asterisk, let’s talk about Streaming some Music on Hold!

Ensuring Streaming Capability

The first step is to ensure that we have the appropriate application for playing our music on hold stream. Because we will be using an MP3 stream, we will want to use mpg123. Unfortunately, the mpg123 application is not included in the Elastix distribution, so, let’s install it. We will also need to install other components/applications associated with mpg123:

Let’s start by downloading the RPM package for mpg123:

[root@server /]# cd /usr/src
[root@server /usr/src]# wget “ftp://ftp.sunet.se/pub/os/Linux/RPMForge/dag/redhat/el3/en/i386/RPMS.dag/mpg123-1.6.2-1.el3.rf.i386.rpm”

Next, well install the required applications to make mpg123 work (if you don’t want to explicitly run these, skip to installing the rpm and install the required application as you are requested):

[root@server /usr/src]# yum install audiofile
[root@server /usr/src]# yum install glibc
[root@server /usr/src]# yum install libtool-ltdl
[root@server /usr/src]# yum install esound

Finally, lets install mpg123:

[root@server /usr/src]# rpm -ivh mpg123-1.6.2-1.el3.rf.i386.rpm

Acquiring a Stream

The second step in configuring streaming music on hold is finding the stream you want to use. For this example, I will use a Digitally Imported stream named Chillout Dreams.

Because of the way that Firefox handles downloads, I’m going to demonstrate accessing the stream file using Firefox:

  1. Open Firefox and browse to www.di.fm
  2. Using the mouse, hover over the DI menu “Listen Now!”, then hover over “Chillout Dreams”, then hover over “MP3 Streams”, and finally click on “96k Cable/DSL”.
  3. Once the download has completed, right click on listen.pls and then click on “Open Containing Folder”.
  4. Using your favorite text editor, mine is UltraEdit, open listen.pls and select the http:// stream for file1 and copy to your clipboard.

Configuring Elastix

Now that you have a stream URL ready for use, open your Elastix web interface and click on the PBX tab.

  1. Under PBX configuration, on the left side of the screen, click on the “Music on Hold” link from the Internal Options & Configuration section.
  2. Now click on the “Add Streaming Category” on the right side of the screen.
  3. In the Category Name field, enter whatever you wish, “DI-Chillout-Dreams”?
  4. In the Application field, enter the following, then paste the stream URL at the end of the application string (replacing [streamURL] of course):

/usr/bin/mpg123 -q -s –mono -r 8000 -f 8192 -b 0 [streamURL]

Now that you have the Music on Hold defined, we need to configure your inbound and outbound routes to use the music on hold:

  1. Click on the “Outbound Routes” and then click on your route(s), then in the drop down list for “Music on Hold?”, choose your new music on hold category.
  2. Click on the “Inbound Routes” and then click on your route(s), then in the drop down list for “Music on Hold?”, choose your new music on hold category.

On the Back End

When  you created the music on hold category/application, the Asterisk file modified is /etc/asterisk/musiconhold_additional.conf, which is included in the base music on hold file /etc/asterisk/musiconhold.conf.

If you open the conf file in a text editor, you’ll notice the category/application that you added earlier.

-Aaron

5 Comments

  1. mostafa said:

    mpg123 can’t play all stream format (like mms), is there another player?

    April 22, 2011
    Reply
  2. Manuel said:

    Hi,
    I followed your instructions, then I changed the “defaul music on hold” to

    [default]
    mode=custom
    application=/usr/bin/mpg123 -q -s –mono -r 8000 -f 8192 -b 0 http://u15.di.fm:80/di_chilloutdreams

    stop / start amportal and just have noise.
    Any idea?

    Thanks for your help

    Manuel

    June 6, 2011
    Reply
  3. said:

    Wow! After wrestling with MoH uploading issues and the notorious “Sox” error messages, I found your article. Immediate success!

    THANKS SO MUCH for your contribution to resolving this issue!

    I’m placing the error message here so this article will hit for relevant searches:
    SOLVED: “sox failed to convert file and original could not be copied as a fall back”

    October 16, 2011
    Reply
  4. m said:

    Tried this with Elastix 2.3.0-6.

    Now the System panel and PBX/OperatorPanel do not work anymore…

    June 30, 2012
    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *