|
First of all my sincere apologies to all on the previous tutorial on Music On Hold - Streaming Internet Radio, especially user ramoncio who made it clear in his post that it couldn't work.
I have spent time pouring over what was in the tutorial, and several more hours trying to work out why it was written totally incorrect. I have never written something so badly. I can only assume that when I finally published it, that several notes came together (I was working on three separate methods at the same time to find which worked best).
Anyhow that aside, I have now worked through, and updated, using latest libraries, the Streaming Music On Hold Tutorial. It covers both Freepbx 2.4 and earlier and also Freepbx 2.5 which includes some improvements for Streaming Music On Hold. Furthermore it has been tested on several fresh builds of Elastix 1.3 and Elastix 1.4 (in beta at time of writing) to make sure that it has been thoroughly tested.
Before you start on this tutoral, you need to make yourself aware of the legalities relating to your country in relation to using Radio/Internet Streams on your PBX system. It is regarded as re-broadcasting for public use, and may be covered by licences such as Public Performance Licences, and Performing rights licences. In many cases it could be two or more licences that you need. In most cases the cost is annual and generally the costs are not over the top. It is up to you to confirm what your countries laws are before implementing this solution.
STREAMING MUSIC ON HOLD FOR FREEPBX 2.4 & EARLIER
First of all lets download the latest mpg123 application. via the Linux Console or via SSH, at he Linux prompt type the following commands
cd /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
rpm -ivh mpg123-1.6.2-1.el3.rf.i386.rpm
There is a slightly newer version (1.6.2-8) but the only rpms that are available are from ATRPMS, and either they have built them incorrectly, or mpg123 in that version requires further dependencies, which are not readily available without loading further rpms with further dependencies. So stick with this version for now.
add the following lines to /etc/asterisk/musiconhold_custom.conf (if other lines are in this file, just add those lines)
[uptemposmoothjazz]
mode=custom
application = /usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://208.122.59.30:7716
[bestofeighties]
mode=custom
application = /usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://160.79.128.62:6618
[Classical]
mode=custom
application = /usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://208.122.59.30:7064
[ClassicalGuitar]
mode=custom
application = /usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://208.122.59.30:7070
When you have selected your list of classes you need to create directories, otherwise Freepbx will not automatically add the classes to the list of Music On Hold. So for the above classes we perform the following:
mkdir /var/lib/asterisk/mohmp3/uptemposmoothjazz
mkdir /var/lib/asterisk/mohmp3/bestofeighties
mkdir /var/lib/asterisk/mohmp3/Classical
mkdir /var/lib/asterisk/mohmp3/ClassicalGuitar
Now we make those directories accessible to asterisk.
chown asterisk:asterisk /var/lib/asterisk/mohmp3/uptemposmoothjazz
chown asterisk:asterisk /var/lib/asterisk/mohmp3/bestofeighties
chown asterisk:asterisk /var/lib/asterisk/mohmp3/Classical
chown asterisk:asterisk /var/lib/asterisk/mohmp3/ClassicalGuitar
Now that is completed, go back into Freepbx to your Music On Hold Menu and you should now see the new music categories that you have

Thats it, you will now find under your inbound routes, ringgroups, queues, the MusicOnHold options now include your new music classes.
Just in case you have seen other examples, using stream.mp3 as a dummy file, you do not need the in this setup. This has been tested with Elastix 1.2, Elastix 1.3 and Elastix 1.4.
STREAMING MUSIC ON HOLD FOR FREEPBX 2.5 AND FURTHER
As of Freepbx 2.5, they have now made it even easier to using Internet Streams by including a Streaming Category option in the Music on Hold Menu.
However we still need to add mpg123 to the system to allow it to play streams, so at the Linux console or via SSH, perform the following commands
cd /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
rpm -ivh mpg123-1.6.2-1.el3.rf.i386.rpm
Now lets go to the Music On Hold section in the Unembedded Freepbx

All you do is select Add Streaming Category and you will see a screen like the above. Fill in the details similar to the example below

The Category name is like the one in the Freepbx 2.4 version, where we selected a category name of uptemposmoothjazz, and the line is /usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://208.122.59.30:7716, which is the Internet feed that we used in the Freepbx 2.4 version.
Submit your changes and thats it. You will end up with a new Music Category to choose from similar to below. You can set up many more as you please.
WHERE CAN I GET INTERNET STREAMS
This is where a lot of people are coming undone, or becoming confused. They read a few tutorials about how to use Internet Streams, they go to their favourite Radio Station, find a feed and try to run it on Elastix. Many of the links now provided by the Internet radio stations download a file called something.pls. The PLS extension being most common which is a play list. This is not suitable for the command line players that are used with Linux, so you hit a stop right there....
Quite often I start off with www.shoutcast.com which has heaps of Internet feeds all at a click of a mouse. Generally I do not click on "click here to listen" but use the actual link to the radio station. Once I reach the radio stations site, I look for their links.
As a guide, I am going to pick one as they have a good selection of music types, as well as a range of feeds based on Bandwidth. For your interest, these feeds were used in the actual code for Elastix/Freepbx that were listed previously in this article. The site I visited was http://www.sky.fm/
So on the site, I found the "Listen Now" menu, then found a Genre of music that I wanted and then selected MP3 Streams (to make life simple, the MP3 are the feeds we want), and then I found a further choice of Bandwidth. Remember we going to use it with Telephony here, not a fantastic sound system, so actually smaller is better as long as you are happy with the sound quality.
So in this case I selected 24k Modems which I find are ok on Asterisk based systems such Elastix

If you select this, you will find that it will try and download a file with an extension called PLS. (Note: if you already have player on your Workstation system that accepts the PLS such as Winamp, you will need to save it as a file and use a file view to look at the contents. Basically the file contents will look like the following:
[playlist]
NumberOfEntries=3
File1=http://212.23.5.99:8002
Title1=S K Y . F M - Best of the 80s - hear your classic favorites and relive those retro 80s!
Length1=-1
File2=http://shoutcast01.edpnet.net:8766
Title2=S K Y . F M - Best of the 80s - hear your classic favorites and relive those retro 80s!
Length2=-1
File3=http://160.79.128.62:6618
Title3=S K Y . F M - Best of the 80s - hear your classic favorites and relive those retro 80s!
Length3=-1
Version=2
All we are after out of this file is one of the entries. I recommend that you try each one in the list in your favourite Media Player (e.g. Windows you might use the Windows Media Player). As you might find a server that has gone offline, or reacts very slow which is not what you want. In fact this one was a very good example, and on testing found the first one didn't seem to respond at all (possibly offline) and the second was slower to start than the third. So for this example I chose the third one.
So after testing, if we take the third one in the list, it would mean our feed address for an MP3 stream for this type of music is http://160.79.128.62:6618
The above are just examples, you can add more, or change the ones above. You may want to find some low bandwidth streams that are closer to your Country to eliminate any dropouts etc.
Credits: ramoncio - For pointing out that the previous MOH tutorial was absolutely useless and did not have a chance of working. Again my apologies for not correcting sooner. Hopefully this up-to-date and more indepth tutorial goes someway to making up for it.
|