ftocc

HOWTO: Streaming music on hold

mrojas73
Posts: 94
Member Since:
2006-06-03

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.

[code]
mpg123 –v
[/code]

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.

[code]
cd /usr/bin
wget http://www.mpg123.de/mpg123/mpg123-0.59r.tar.gz
tar –zxvf mpg123-0.59r.tar.gz
cd mpg123-0.59r
make linux
make install
ln -s /usr/local/bin/mpg123 /usr/bin/mpg123
[/code]

Now you need to make a directory for the streaming music, do the following:

[code]
cd /var/lib/asterisk/mohmp3/
mkdir stream
[/code]

Make a zero length dummy mp3 file inside of the stream directory, do:

[code]
cd stream
touch stream.mp3
[/code]

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.

[code]
nano -w /etc/asterisk/musiconhold.conf
[/code]

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.

[code]
[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
[/code]

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:

[code]
amportal restart
[/code]

Add an extension in extensions_custom.conf for testing.

Anywhere between [from-internal-custom] add the following extension:

[code]
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
[/code]

Ctrl+x, y and enter to save the changes.

Restart asterisk:

[code]
amportal restart
[/code]

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.



fofusion
Posts: 26
Member Since:
2006-08-24
Re: HOWTO: Streaming music on hold

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



stokecpa
Posts: 15
Member Since:
2006-09-26
Re: HOWTO: Streaming music on hold

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!



mrojas73
Posts: 94
Member Since:
2006-06-03
Re: HOWTO: Streaming music on hold

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!

Quote:
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!



PalletBoy
Posts: 30
Member Since:
2006-12-19
Re: HOWTO: Streaming music on hold

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



mustardman
Posts: 1214
Member Since:
2006-06-18
Finally got it working after

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?



cosmos
Posts: 27
Member Since:
2007-05-06
I also Wasted most of the

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???



mustardman
Posts: 1214
Member Since:
2006-06-18
With mpg123 v0.59r I was

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.



Undrhil
Posts: 264
Member Since:
2006-06-25
So, for those of us using

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.



webboy
Posts: 9
Member Since:
2007-04-09
What Rate

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



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.