You can set a specific class from where you want the music to be played. There is a class which is set by default. It will be used in case of omitting the class argument of the application. The default class could be changed by the help of the SetMusicOnHold application.

This application does not have an option for stopping the music, so the only way to interrupt the music on hold is to hang up the line.

So, what for you can use this application? We suggest that you can use it, when you want to play a non-stop message about something. For example: If the call is made between 15:00 and 08:00 it can be redirected to the MusicOnHold application and the caller could hear a message like this one: Please, contact us during the work time between 08:00 and 15:00! Thank you!.

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.

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.

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 15:00 o’clock, the call will be connected to the extension with priority 4. 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 15:00 and 08:00 o’clock the next executed extension will be the one with priority 3. This one will execute the MusicOnHold application. It will play the sound file with the message Please,contact us during the work time between 08:00 and 15:00! Thank you!. The sound file should be put in the default directory, which in our case is /var/lib/asterisk/mohmp3. In your case it could be different. If you want to change the default directory use the SetMusicOnHold application.

NOTE: Please, pay attention that the SetMusicOnHold application will change only the class for the music on hold directory. You have to define this class in the musiconhold.conf file.

The MusicOnHold application will repeat 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

ishaq hussain (x_26230 at yahoo dot com)22 March 2007 09:37:44how to configure for audio on hold.

Pratik (pthakkar at adiance dot com)13 November 2005 06:16:34Hi,
I want to put Video on Hold for our application.
For that I don't know how to configur video file with asterisk.
If anyone knows then please reply me.

Thanking you
Praitk

Russ (rclark at clarkcc dot com)24 October 2005 16:48:01For some reason I am unable to see these images. I am ver intrested in what you did here.

Add Comment

Name:

Email:

Comment:

In order to prevent automatic posting on our website, we kindly request you to type in the number you see in the picture below.