1. SetMusicOnHold - this application allows you to change the default class for the music on hold.
NOTE: This application is valid for Asterisk version 1.0.9 and above.
Syntax:
SetMusicOnHold(class)
Purpose and usage
Thanks to this application you can change the default class, used by the MusicOnHold application. The class indicates the directory, where the sound files for the music on hold have to be stored.
Please do not forget that this application will change the default class, not the default directory. The default directory could be changed and assigned to a specific class in the musiconhold.conf file.
To see how the application works we recommend to use our IAX softphone Idefisk. You can download it from here. Please also read our tutorial to learn how to configure it to work with Asterisk PBX.
Asterisk PBX configurations
NOTE: This is only an example of what for you can use this application. Of course you can use it and for other things.
iax.conf Configurations
We need two registered users in iax.conf file. This is because we are going to use the IAX2 protocol. If you want to use other protocol such as SIP or MGCP, you have to do the configurations below respectively in sip.conf or mgcp.conf.
So, we have registered the users anatoliy and ivan
Type=friend means that this user can make and receive calls. Host=dynamic means that the IP is not static but dynamic through a DHCP server. Allow=all means that the line which this user will use, could support all audio codecs. Context=test - this shows that this user is working with the extensions in this context of the configuration file extensions.conf.
musiconhold.conf Configurations
On the picture below, is our musiconhold.conf file. As you can see, we have two lines. The first one starts with the word default, the second one with the word loud. These are the names of the classes. These names, you have to use as argument in the brackets of the SetMusicOnHold.
To the name of the classes you have to assign a directory. In our example we have assigned for the class default, the directory /var/lib/asterisk/mohmp3. For the class loud, we have assigned the directory /tmp.
Now, there is a slight difference between MusicOnHold and SetMusicOnHold applications. With SetMusicOnHold you can change the default class, but you cannot play the sound file.
MusicOnHold also has an argument for changing the class. However, it does not change the default class. It will just use another class.
The default class is used only if there is no class set as argument, in the brackets of the MusicOnHold application. In other words, if you leave the space, between the brackets, blank, then the default class will be used.
In our example we will leave the space between the brackets of the MusicOnHold application blank. The system will use the default class, which in our example will be set to loud thanks to the SetMusicOnHold application. This class indicates the directory /tmp, so the sound files for the music on hold will be played from that directory.
What will happen in our example? When somebody dials 12345, the call will be answered by the Answer application. The next executed extension will be the one which contains the GoToIfTime application. According to the current time the incoming call will be redirected by the help of this application. If the time interval is between 08:00 and 13:00 o’clock, the call will be connected to the extension with priority 5. This extension will execute the Dial application. Thanks to it the call will be connected to the user ivan through the IAX2 channel.
If the incoming call is made in the time interval between 13:00 and 08:00 o`clock the next executed extension will be the one with priority 3. This one will execute the SetMusicOnHold application. It will set the default class to loud. The loud class indicates the directory /tmp. So now the directory, from where our sound files will be play by the MusicOnHold application, is /tmp. The execution will now continue with the next extension, which contains the MusicOnHold application. It will play a sound file with a message. The message could be something like that: Please, contact us during the work time between 08:00 and 13:00! Thank you!. Since our directory now is /tmp, you should to put the sound file with the message here.
The MusicOnHold application will continue to play the sound file unless the user hang up the line.
In order to be sure, that the Asterisk PBX will hang up the line after the conversation is over, it is always a good idea to make an extension for hanging up.
2. Screenshots of what you can see on the CLI of the Asterisk PBX
3. Additional information
For more information about extensions.conf you can check here.
For more information about iax.conf you can check here.
This application is tested with our IAX softphone Idefisk. You can download it from here. For more information about this softphone please read our tutorial.
If you would like to test this application with the SIP channel you can read our tutorials about the SIP Softphones to learn how to configure them to work with Asterisk PBX
User Comments
online doctor prescription for cialis (irving_sorenson at grassfed dot us) 03 July 2020 01:00:46 online doctor prescription for cialis https://www.wisig.org/
AAssusHATKaws (serbFerswrendy at clifors dot xyz) 22 June 2020 14:46:13 <a href="https://cialisle.com/">buy cialis tadalafil</a>
https://careprost.confrancisyalgomas.com (kandacerestrepov at tolbe dot ml) 17 June 2020 15:42:51 https://careprost.confrancisyalgomas.com https://careprost.confrancisyalgomas.com/
Eternity (qy335x3s94 at hotmail dot com) 21 April 2016 03:40:35 Good job maikng it appear easy. http://wupqfxjnpm.com [url=http://bhgmrytcs.com]bhgmrytcs[/url] [link=http://jfobsxxadl.com]jfobsxxadl[/link]
Jenny (h3ij8nszf at gmail dot com) 19 April 2016 14:58:29 At last! Someone with the insight to solve the <a href="http://tugvywva.com">prebmol!</a>
Lyndee (tzonqetyu at yahoo dot com) 19 April 2016 06:00:06 Ho ho, who <a href="http://bmpizy.com">woudla</a> thunk it, right?
Kako (klxg73abw3 at yahoo dot com) 09 October 2015 17:47:19 Actually, I let a plugin to all of my inetnral linking for me now. It looks at how my other posts are tagged and finds the appropriate keyword in the content. I am so slack about linking to my own content that this is the only way it will happen Sometimes it goes a little crazy though. http://dmlmestxwn.com [url=http://dzoxsjiezs.com]dzoxsjiezs[/url] [link=http://cctqpjb.com]cctqpjb[/link]
Open (fk3wq0g4uks at gmail dot com) 09 October 2015 09:32:08 How do you know each other? angel preteen <a href="http://qwixpu.com">loltia</a> model wow she getting pounded so good , coming heavy she running out and gets filled , would love to be in her position
Open (057nvtvaan8 at yahoo dot com) 09 October 2015 03:12:25 Gracias por lo que toca XDPues a med ya me gustareda que se aputsane me1s gente, a ser posible que sepan menos que yo, ased puedo hacer como que ayudo http://zjcixapzxw.com [url=http://cpqnvyxoa.com]cpqnvyxoa[/url] [link=http://tftlwiqc.com]tftlwiqc[/link]
Jaskaranpreet (pyi7gggbz2t at yahoo dot com) 25 September 2015 12:26:15 This was so helpful and easy! Do you have any arltcies on rehab?
Paul (paul at feefifofum dot com) 28 October 2006 19:52:57 You need to convert the mp3 file to a gsm file.
howard ho (hho at tri-m dot com) 09 June 2006 21:40:06 I can play any of the MP3 files from mohmp3 folder using MP3Player() command. But no sound is heard from any GXP2000 when I use musiconhold()