login | register
Wed 09 of Jul, 2008 [05:15 UTC]

voip-info.org

Discuss [12] History

Asterisk cmd MusicOnHold

Created by: oej,Last modification on Thu 06 of Dec, 2007 [18:21 UTC] by denis.araujo68

Synopsis

Play Music On Hold indefinitely.

Description

   MusicOnHold([class])

Plays hold music specified by class. If omitted, the default music source for the channel will be used. If you have configured MusicOnHold in musiconhold.conf it will get played automatically if the extension is put on hold. This command FORCES musiconhold music.

The default MusicOnHold class is set with the SetMusicOnHold command.

Example

Extension defined in extensions.conf with "forced" MusicOnHold. Remember to Answer before letting the music pour down the line. Otherwise music on hold will not work correctly.
   ; Answer required as Music On Hold does not answer the call
   exten => 6000,1,Answer
   exten => 6000,2,MusicOnHold()

It is often useful to turn off music on hold in several situations:
  1. when a particular extension calls (originates)
  2. when connectiong to a particular extension
  3. when traversing a particularly expensive network
  4. when connecting to a conference


(So, how do we do handle each situation?)

You can turn off MOH on a per call by using the SetMusicOnHold command.

Add a new class to musiconhold.conf
   [none]
   mode=files
   directory=/dev/null

Create a macro in extensions.conf to turn off MOH
   [macro-nomusic]
   exten => s,1,NoOp(Turn off MOH for this channel)
   exten => s,2,SetMusicOnHold(none)

Now call this macro when you dial an extension
    exten => 7020,1,NoOp(Dial -> IAX2/outbound/${EXTEN})
    exten => 7020,n,Dial(IAX2/outbound/${EXTEN},,M(nomusic))
    exten => 7020,n,Hangup

play-fifo (3rd party addition)

This small C program will create if necessary, open and listen on a fifo for slinear audio and delivers it to STDOUT. If STDOUT is blocking, it discards the data. The idea is that you would use it in a custom class in res_musiconhold. Now you can use whatever means you choose in a seperate process to deliver raw 8khz mono slin to the fifo which will be heard as the music class fifo. An example would be to play your line-in into the fifo and the buffer will not overflow because this program does a poll on the STDOUT and discards STDIN when STDOUT is busy.
You can find it here, it is not part of the Asterisk distribution.

See also



Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ


Comments

Comments Filter
222

333

by mattfox71, Tuesday 13 of May, 2008 [05:13:07 UTC]
222

333

by mattfox71, Monday 12 of May, 2008 [22:35:36 UTC]
We have just upgraded to 1.4.20-rc1 and found that the following method to turn off music on hold no longer works, it just reverts to the default moh class which we use for our IVR. Basically we are trying to turn off the MOH for agents and even playing a silence sound file produces noise on the line that you can hear in a quiet environment. Does anyone have any other suggestions?


  none 
  mode=files 
  directory=/dev/null 

222

333My MOH isnt working.

by cutter5o, Friday 15 of June, 2007 [03:34:44 UTC]
features
 
;MeetMeConferenceRoom 1
exten => 510,1,MeetMe(510,i,54321)

;MOH
exten => 520,n,MusicOnHold(default)

include = parkedcalls

222

333Music on hold quality

by lumpy, Thursday 18 of January, 2007 [17:27:26 UTC]
I had some trouble with the music on hold quality and did the following:
Removed previous MPG123 which was in /usr/local

Installed different version of mpg123
1.) cd /usr/local
2.) wget http://superb-west.dl.sourceforge.net/sourceforge/mpg123/mpg123-0.59r-gpl.tar.gz
3.) tar zxvf mpg123-0.59r-gpl.tar.gz
4.) cd mpg123-0.59r-gpl
5.) make linux
6.) make install

Your etc/asterisk/musiconhold.conf configuration should look like the following:

;
; Music on Hold --
;

default
mode=quietmp3
directory=/var/lib/asterisk/mohmp3

Your /etc/asterisk/Zapata.conf should look something like the following:


channels
relaxdtmf=yes
; group 5
;
language=en
signalling=em_w
rxwink=300
switchtype=national
emdigitwait=2000
usecallerid=yes
threewaycalling=yes
transfer=yes
musiconhold=default
busydetect=no ;leave this on for detecting hangups
;jitterbuffers=10
;echocancel=yes
;echocancelwhenbridged=yes
group=5
channel => 1-24

You should also have at least one MP3 file on /var//lib/asterisk/mohmp3
222

333Legal Requirements

by Pepperdotnet, Friday 22 of September, 2006 [22:08:05 UTC]
Be sure to meet any legal requirements for music-on-hold.

I hope somebody with a legal background will comment on this because I really don't know. Are the three mp3 files included in the Asterisk distribution royalty-free or do we need to pay somebody for the right to use them in a production environment? (this is probably documented somewhere but I haven't found it yet) I do know the included files came from www.freeplaymusic.com and that the FAQ there mentions a licensing fee for music-on-hold usage, don't know if this is "grandfathered" for the three included files though. Ideas?
222

333Cant turn it off , but can CHANGE it....

by Cerebral, Wednesday 15 of February, 2006 [18:52:27 UTC]
I wanted to have my FAX line to ring instead of music on hold so that it does not confuse any fax machines with the music. Here is what i came up with to change it in my stealth auto attendant:

exten => 111,1,Zapateller(answer|nocallerid)
exten => 111,2,SetMusicOnHold(default)
exten => 111,3,DigitTimeout,3
exten => 111,4,ResponseTimeout,3
exten => 111,5,Background(custom/welcome)

exten => 0,1,Dial(local/420@from-internal,35,m)
exten => 0,2,VoiceMail(420@default)
exten => 0,3,Hangup
exten => 1,1,Dial(local/499@from-internal,20,m)
exten => 1,2,Hangup
exten => 7,1,Authenticate(1234)
exten => 7,2,DISA(no-password|from-internal)

In the Dial lines above (exten => 1,1,Dial(local/499@from-internal,20,m) the last "m" denotes play music while waiting, by simply changing the "m" to an "r" it will pass the regualr ring tone instead of music, like this:

(exten => 1,1,Dial(local/499@from-internal,20,r)

Worked great!

Cerebral
222

333Cant turn it off , but can CHANGE it....

by Cerebral, Wednesday 15 of February, 2006 [18:50:01 UTC]
I wanted to have my FAX line to ring instead of music on hold so that it does not confuse any fax machines with the music. Here is what i came up with to change it in my stealth auto attendant:

exten => 111,1,Zapateller(answer|nocallerid)
exten => 111,2,SetMusicOnHold(default)
exten => 111,3,DigitTimeout,3
exten => 111,4,ResponseTimeout,3
exten => 111,5,Background(custom/welcome)

exten => 0,1,Dial(local/420@from-internal,35,m)
exten => 0,2,VoiceMail(420@default)
exten => 0,3,Hangup
exten => 1,1,Dial(local/499@from-internal,20,m)
exten => 1,2,Hangup
exten => 7,1,Authenticate(1234)
exten => 7,2,DISA(no-password|from-internal)

In the Dial lines above (exten => 1,1,Dial(local/499@from-internal,20,m) the last "m" denotes play music while waiting, by simply changing the "m" to an "r" it will pass the regualr ring tone instead of music, like this:

(exten => 1,1,Dial(local/499@from-internal,20,r)

Worked great!

Cerebral
222

333Turn OFF Music on Hold

by rgrokett, Friday 27 of January, 2006 [02:06:00 UTC]
Well, there's plenty of talk about how to turn MOH ON, but I see nothing on how to TURN IT OFF! I'd like to turn it off on certain phones, so as to not put out music when I happen to be on a conference call. But, I'd settle for completely turning it off, if I can't individually control it.

Ideas?

222

333MusicOnHold never triggered!

by avizion, Thursday 29 of July, 2004 [12:41:30 UTC]
My system is Debian3 running 2.6.7 with Asterisk CVS-HEAD-07/23/04-11:30:06.

For some reason my MOH was never triggered when anyone called either of my 5 queues. I tried all setting I could think off before I turned to the mailing list.

I used some hours on this - so I hope this can help others...

This is a snippet from my mail at the asterisk-users mailing list (Link to archive):

It seems that the script /usr/sbin/safe_asterisk is never replaced when you "make install" in asterisk. While it's nice that your own hacks are preserved, I think it would be a lot nicer to have a warning if that file was updated since your last install - and it could simply backup your existing safe_asterisk and replace it with the updated version.

I did not actually find out the real reason why that safe_asterisk script did not work in the first place. Maybe someone more experienced can answer that better.

Solution: replacing the safe_asterisk with whatever HEAD version I had downloaded last made "everything" (about MOH) work.

Or: Simply run asterisk manually and/or with your own "safe" wrapper.
222

333Re: mpg123 ver. 0.59s

by , Monday 12 of July, 2004 [22:49:52 UTC]
mpg123 0.59s has broken -f (scaling) processing.

asterisk passes -f 32768 and -r 8000. currently only passing it -f 1 seems to work (to version 0.59s). I have not tested to see if the -r 8000 parameter is part of the problem or not.

asterisk has no current way to change the -f parameter to 1, besides a source code change. I could not find out where the problem lay in mpg123-0.59s, as the changes (between 0.59s and 0.59r) that I spotted seemed benign.

in anycase 0.59r does work with the current asterisk code. I would like to see an overhaul in the MOH options. Like being able to specify your entire commandline (so that you can run OGG files or whatever).