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:
- when a particular extension calls (originates)
- when connectiong to a particular extension
- when traversing a particularly expensive network
- 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
- MusicOnHold Configuration
- Asterisk cmd SetMusicOnHold
- Asterisk cmd MP3Player
- Sounddogs Royalty Free Music
- Signate Free Music On Hold Free Classical Music on Hold in MP3,ULAW and SLN
- BMI Commercial Music Licenses
- Using ffmpeg to convert Music On Hold files Convert to WAV and u-Law PCM in one step using ffmpeg
- Using ffmpeg to convert to Asterisk Native SLN Convert just about any audio to Asterisk Native SLN using ffmpeg
- Using Slimserver for Music on Hold: How to use a local or remote slimserver for your Music on Hold
- Asterisk MoH Patch How to play native file formats in asterisk
- StarTel has a large collection of MP3's suitable for Music on hold
- Configuration
- Sound files
Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ
Comments
333
333
none
mode=files
directory=/dev/null
333My MOH isnt working.
;MeetMeConferenceRoom 1
exten => 510,1,MeetMe(510,i,54321)
;MOH
exten => 520,n,MusicOnHold(default)
include = parkedcalls
333Music on hold quality
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
333Legal Requirements
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?
333Cant turn it off , but can CHANGE it....
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
333Cant turn it off , but can CHANGE it....
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
333Turn OFF Music on Hold
Ideas?
333MusicOnHold never triggered!
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.
333Re: mpg123 ver. 0.59s
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).