HOWTO: Streaming music on hold
HOWTO: Streaming Music On Hold on TrixBox.
These instructions are borrowed from Alan at ServerPacket.com
(http://community.serverpacket.com/showthread.php?p=22). I just wanted to show how to get the URL from a live stream on Real Player and Window Media Player so that you can use your favorite station on Trixbox by following this guide.
PLEASE: USE THIS GUIDE AT YOUR OWN RISK, I DON'T KNOW THE LEGAL SIDE OF STREAMING MUSIC, SPECIALLY COPYRIGHTED MATERIAL. DO YOUR RESEARCH.
The first thing you have to do is find out if you have mpg123 player installed on your system, we need version 0.59r or later installed.
In command prompt type the following, if the player is installed the return will show you the version you are running on top of the result.
mpg123 –v
If the player is not installed, or you have an older version download and install version 0.59r by typing the following in command prompt, one line at the time.
cd /usr/bin wget <a href="http://www.mpg123.de/mpg123/mpg123-0.59r.tar.gz" title="http://www.mpg123.de/mpg123/mpg123-0.59r.tar.gz">http://www.mpg123.de/mpg123/mpg123-0.59r.tar.gz</a> tar –zxvf mpg123-0.59r.tar.gz cd mpg123-0.59r make linux make install ln -s /usr/local/bin/mpg123 /usr/bin/mpg123
Now you need to make a directory for the streaming music, do the following:
cd /var/lib/asterisk/mohmp3/ mkdir stream
Make a zero length dummy mp3 file inside of the stream directory, do:
cd stream touch stream.mp3
Edit the musiconhold.conf file.
Musiconhold.conf is where you add your music code! You will need to have the URL of the radio station you want to play, I will show you how to get it (which is the part most guides don’t tell you). Like I mentioned in the beginning, I have been using my streaming music from www.shoutcast.com, the guy who wrote this, Alan uses www.radioio.com. It is up to you, personally I like shoutcast because of their big selection. You can change your radio station streaming everyday if you want to.
Go to shoutcast and find the station you like by clicking on the tune in button. You need to have RealPlayer to play most of their music, once the music starts playing go to File >clip properties >View Clip Info or you can do a Ctrl+I. Write down the filename which should look like this: http://62.75.220.137:9006 (this is the URL we need).
If you get to a station that uses Windows Media Player, the URL can be found by going to: File>Properties; location is what you want.
Okay, time to add our streaming stations to the musiconhold.conf file, do the following to open and edit the file.
nano -w /etc/asterisk/musiconhold.conf
On the very top of the file enter the following command; just replace the URL with the one of the radio station you want to use.
Leave everything else unchanged, so that your file looks like the following: Default =>...quiet has to one line.
[classes] default =>quietmp3:/var/lib/asterisk/mohmp3/stream,http://64.202.98.180:80/ [moh_files] default => /var/lib/asterisk/mohmp3,r #include musiconhold_additional.conf ; class definition for Streaming MOH ;stream => quietmp3:/var/lib/asterisk/mohmp3/stream ; class definitions For A2Billing acc_1 => mp3:/var/lib/asterisk/mohmp3/acc_1 acc_2 => mp3:/var/lib/asterisk/mohmp3/acc_2 acc_3 => mp3:/var/lib/asterisk/mohmp3/acc_3 acc_4 => mp3:/var/lib/asterisk/mohmp3/acc_4 acc_5 => mp3:/var/lib/asterisk/mohmp3/acc_5 acc_6 => mp3:/var/lib/asterisk/mohmp3/acc_6 acc_7 => mp3:/var/lib/asterisk/mohmp3/acc_7 acc_8 => mp3:/var/lib/asterisk/mohmp3/acc_8 acc_9 => mp3:/var/lib/asterisk/mohmp3/acc_9 acc_10 => mp3:/var/lib/asterisk/mohmp3/acc_10
You need to save the file. Do a Ctrl+x, type y when asked if you want to save it and hit enter to save it.
Restart asterisk with the following command:
amportal restart
Add an extension in extensions_custom.conf for testing.
Anywhere between [from-internal-custom] add the following extension:
exten => 466,1,Answer exten => 466,2,Playback(pls-hold-while-try) exten => 466,3,SetMusiconHold(default) exten => 466,4,WaitmusiconHold(60) exten => 466,4,Hangup
Ctrl+x, y and enter to save the changes.
Restart asterisk:
amportal restart
Dial 466 and your music should start playing immediately.
You may have to restart your server, if you encounter any problems go back and check all your steps.
Good luck.
Note: The doted lines aren't part of the code, I used them to separate it from the rest of the writting.
sorry to post in an old topic but thank you ;-)
I used your guide and successfully implemented streaming audio for my asterisk box :-D
Barry
Trixbox has changed the layout of musiconhold.conf beginning with 1.2.1. Can anyone specify how to configure the new version for streaming music on hold. The new file now looks like this:
;
; Music on hold class definitions
; This is using the new 1.2 config file format, and will not work with 1.0
; based Asterisk systems
;
[default]
mode=files
directory=/var/lib/asterisk/mohmp3
#include musiconhold_additional.conf
Thanks for your help!
It is the same, just comment out everything like this:
; [default]
; mode=files
; directory=/var/lib/asterisk/mohmp3
#include musiconhold_additional.conf
And follow the guide!
stokecpa wrote:
Trixbox has changed the layout of musiconhold.conf beginning with 1.2.1. Can anyone specify how to configure the new version for streaming music on hold. The new file now looks like this:
;
; Music on hold class definitions
; This is using the new 1.2 config file format, and will not work with 1.0
; based Asterisk systems
;
[default]
mode=files
directory=/var/lib/asterisk/mohmp3
#include musiconhold_additional.conf
Thanks for your help!
Got streaming CoH working, great and simple guide! Bravo.
Question: If I want to use a station that only streams in Windows Media format @ 16k is there an argument I can change to get it to work?
Am having no success in getting it to stream.
Thanks!
-PalletBoy
Finally got it working after wasting half of a perfectly good Saturday. Note to other people. Use mpg123 v0.59r and not the latest which is at 0.64 or there abouts. It refused to work properly.
Wasted the other half of a perfectly good Saturday trying to stream a station that uses asf/asx/wmv or whatever using mplayer. Tried all the permutations from the Asterisk Wiki but none of them worked. Anyone have any luck streaming Microsoft Media audio?
I also Wasted most of the day today on this.. But i did get streaming to work!! I use http://64.236.34.97:80/stream1040
Seems like the is a limited amout of streams that will play successfully.... Does anyone else have any good ones thy are using???
With mpg123 v0.59r I was able to get every station I tried on shoutcast working. With the newer version of mpg123 it was much more finicky.
The problem is that the local station everyone uses for background music on their PBX's in my area uses windows media streaming. The only linux player I found that claimed to work with windows media streaming is mplayer but I couldn't get it to work.
So, for those of us using Trixbox (imagine that: a Trixbox user on the Trixbox forums!) how does this guide translate for use with musiconhold_additional.conf and musiconhold_custom.conf? I just want to make sure it's all compatible with FreePBX and stuff, you know?
EDIT: OK, for getting this to work from within FreePBX, you make the changes to the musiconhold.conf file (or you can make the change in musiconhold_additional.conf and leave musiconhold.conf alone. Be sure to comment out the existing [default] context in musiconhold_additional.conf.
In FreePBX, choose the 'inherit' MOH class to use the streaming music.
Hi all
I have managed to stream the music from the server , But for the stream what would be the recommend rate i should stream this at so it dose not take up much bandwidth
32 Mono
16 Mono
any good ideas
I just tried this on 2.6.2.2 and it still works fine.
Thanks
Damien
I posted this Howto a long time ago but got out of PBX do to a job change, but I am trying to come back and add telephony to my IT offerings since I got the experience...very surprised to have stumbled upon this old thread!
I guess I will have to try it again :)
When I type in "make linux" I get this error:
[trixbox1.localdomain mpg123-0.59r]# make linux
make CC=gcc LDFLAGS= \
OBJECTS='decode_i386.o dct64_i386.o decode_i586.o \
audio_oss.o term.o' \
CFLAGS='-DI386_ASSEM -DPENTIUM_OPT -DREAL_IS_FLOAT -DLINUX \
-DREAD_MMAP -DOSS -DTERM_CONTROL\
-Wall -O2 -m486 \
-fomit-frame-pointer -funroll-all-loops \
-finline-functions -ffast-math' \
mpg123-make
make[1]: Entering directory `/usr/bin/mpg123-0.59r'
make[2]: Entering directory `/usr/bin/mpg123-0.59r'
gcc -DI386_ASSEM -DPENTIUM_OPT -DREAL_IS_FLOAT -DLINUX \
-DREAD_MMAP -DOSS -DTERM_CONTROL\
-Wall -O2 -m486 \
-fomit-frame-pointer -funroll-all-loops \
-finline-functions -ffast-math -c -o mpg123.o mpg123.c
make[2]: gcc: Command not found
make[2]: *** [mpg123.o] Error 127
make[2]: Leaving directory `/usr/bin/mpg123-0.59r'
make[1]: *** [mpg123-make] Error 2
make[1]: Leaving directory `/usr/bin/mpg123-0.59r'
make: *** [linux] Error 2
[trixbox1.localdomain mpg123-0.59r]#
Any ideas?
Thanks!!!
Seems quite simple. You don't have GCC installed which is kinda impressive. Not sure what version of Unix Trixbox normall gets deployed with, but you can always try:
yum -y install gcc
But if you're missing GCC then I expect many more errors to come up. If you have a few bucks, try grabbing someone at www.oDesk.com or another place to do the install for you.
/Nicholas Blasgen
Thank you! I installed GCC and now I get this error;
[trixbox1.localdomain mpg123-0.59r]# make linux
make CC=gcc LDFLAGS= \
OBJECTS='decode_i386.o dct64_i386.o decode_i586.o \
audio_oss.o term.o' \
CFLAGS='-DI386_ASSEM -DPENTIUM_OPT -DREAL_IS_FLOAT -DLINUX \
-DREAD_MMAP -DOSS -DTERM_CONTROL\
-Wall -O2 -m486 \
-fomit-frame-pointer -funroll-all-loops \
-finline-functions -ffast-math' \
mpg123-make
make[1]: Entering directory `/usr/bin/mpg123-0.59r'
make[2]: Entering directory `/usr/bin/mpg123-0.59r'
make[2]: *** No rule to make target `\
', needed by `mpg123'. Stop.
make[2]: Leaving directory `/usr/bin/mpg123-0.59r'
make[1]: *** [mpg123-make] Error 2
make[1]: Leaving directory `/usr/bin/mpg123-0.59r'
make: *** [linux] Error 2
As you can see I am a Linux newbie, thanks to all for your help!
Cheers
ChicoCanada - What does this post have to do with MOH?
Unless I am missing something I am going to delete these messages as it appears you have hijacked this thread to discuss compiling the kernel.
I am trying to install the MOH, specifically the player and I am getting errors. I figured I would reply to this post since I thought it to be relevant to the installation of MOH, hoping that others that struggle with the same issue during install might benefit from this info.
Cheers
Scott, it's quite obvious he's not trying to compile the kerne......, cut him some slack.....
Chico, try doing a yum install gcc* and see if that helps.
I read it too fast, that's why I asked. I same the 'make linux' and not sure why 'make kerenel' Sorry to add to the confusion
All you are trying to do is build mpg123? I thought it was in the repo.
I am still not clear what he is trying to do.
I think he's missing all the required compiler components.
This may help:
# Update CentOS # yum update -y --disablerepo=trixbox* # # # yum -y install kernel-devel.i686 yum -y install kernel-headers.i386 # # Install Build Environment # yum -y install rpm-build newt-devel ncurses-devel ibusb-devel gcc* net-snmp* # Link Kernel header to Kernel version # ln -s kernels/2.6.18-128.1.10.el5-i686/ linux ln -s kernels/2.6.18-128.1.10.el5-i686/ linux26 #
Thanks for your advice kspare and Scott, I have installed GCC and also followed Scott's recommendations. Unfortunately I am still stuck... this is the error I get;
[trixbox1.localdomain mpg123-0.59r]# make linux
make CC=gcc LDFLAGS= \
OBJECTS='decode_i386.o dct64_i386.o decode_i586.o \
audio_oss.o term.o' \
CFLAGS='-DI386_ASSEM -DPENTIUM_OPT -DREAL_IS_FLOAT -DLINUX \
-DREAD_MMAP -DOSS -DTERM_CONTROL\
-Wall -O2 -m486 \
-fomit-frame-pointer -funroll-all-loops \
-finline-functions -ffast-math' \
mpg123-make
make[1]: Entering directory `/usr/bin/mpg123-0.59r'
make[2]: Entering directory `/usr/bin/mpg123-0.59r'
make[2]: *** No rule to make target `\
', needed by `mpg123'. Stop.
make[2]: Leaving directory `/usr/bin/mpg123-0.59r'
make[1]: *** [mpg123-make] Error 2
make[1]: Leaving directory `/usr/bin/mpg123-0.59r'
make: *** [linux] Error 2
[trixbox1.localdomain mpg123-0.59r]#
thank you very much for you help and input!
Cheers!
Isn't MPG123 already installed on trixbox 2.6 and 2.8 ???
Since I'm still somewhat a novice, I have no idea, but I'm running Trixbox v2.6.2.3
Cheers and thank you!
At the shell prompt type 'mpg123' and see what happens.
Also try 'yum install mpg123'
I type this in CLI;
[trixbox1.localdomain ~]# mpg123
-bash: mpg123: command not found
So I went ahead and then typed "yum install mpg123" and it installed :-)
I went back to the "make linux" part and got the same error, so I went ahead and ignored "make linux" and "make install" and continued the process as of "ln -s /usr/local/bin/mpg123 /usr/bin/mpg123" and completed the rest of the install guide, but it doesn't work. Any ideas?
Thanks a lot Scott!
Any ideas?
Yes, put a $50.00/us bounty up on the jobs forum and let one of us fix is for you. We can play 20 questions for a decade and never find the answer. 15 minutes in front of the screen and the job is done.
Got this working, but only after I commented out the default section in musiconhold_additional.conf
Call me, I'll put you on hold.
Might be a stupid question but did you try su to run the make? Depending on your permissions you may need to do this:
su make linux
su make install
I've seen some odd errors in the past when I didn't use su.
-graham
There is a streaming MOH section in TB 2.8 It asks for URL's and the like. For the life of me I have no idea what these fields are supposed to be filled in as. Is it just extremely complex, or extremely simple and I am missing the obvious completely?



Member Since:
2006-06-03