Hello all,
I wanna play a single file when call is put on hold. In asterisk it takes the files from moh directory when call is put on hold. I wanna to play a single file from the directory instead of playing the whole file in order or random.

And also i don’t wanna create separe directory , i wanna take the file from moh and plays that single file .


I don’t recognize “wanna” as an English word.

However, it would seem that you would like to do something that you explain can’t be done.

What are your real goals? Why does the use of a separate music class not solve your problem?

I guess if you remove all the files from your MOH directory, and just let the one you need to play you will get you goal.


In MOH directory i do have so many files. In my case i want to play a single file from that directory instead of playing all files in order or random .Also don’t want to delete the remaining file.


Move the files to a different location and just leave the single file, that you want to play.

hi ,

But that i don’t want i want to play a single file how do i do that . For each context i want to set different MOH if i going to create different folder then it won’t look efficient. It would be better to play a file either directly from musiconhold.conf or someother way. Is there any way to do that.


You need to create different classes on your musiconhold.conf. Then use



I want to play a single file whenever the call is put on hold from mulitple file.

For Example: in /var/lib/asterisk/moh have set of file 

CHANGES-asterisk-moh-opsound-wav macroform-robot_dity.wav
CREDITS-asterisk-moh-opsound-wav macroform-the_simplicity.wav
LICENSE-asterisk-moh-opsound-wav manolo_camp-morning_coffee.wav
macroform-cold_day.wav reno_project-system.wav

In this file i need to play manolo_camp-morning_coffee.wav when call is on hold.

Note: I don’t want to create separate folder to put these file and play.

Is there a way to do that?

Thanks …,


Thanks ,

So faced the same issue and had the same question. Thank you for the posts above.

I solved it when I copied all formats of the moh I needed, in a subdirectory of “moh” which named “mine”, created new class “mine” changing musiconhold.conf and adding that new class, the directory path and replaced “default” in extensions.conf with “mine”.

That’s it.

a bit late post , still think if it’ll help someone

you can play single mp3 file for each class

application=/usr/bin/mpg123 -q -r 8000 -f 8192 -b 0 --mono -s /full/path/of/your/file

Playing MP3 is a waste of CPU power. Telephone systems don’t have the audio quality to benefit, so it is better to pre-convert to the actual codec that will be used.

after converting to actual can we use any kind of application to play single file ?? like mpg123 that i used in my example …

If you preconvert you don’t need an application at run time; Asterisk can play the file directly.

asterisk can play all files within a directory , but like helpdesk2014 i wan to play a single file from a directory which contains more then one file

i was thinking about running the single file with an application in custom mode as like mpg123 can play mp3 !! is it possible ?

You can use the rawplayer app.

Look in your contrib/utils directory of your asterisk source, there is a README.rawplayer that will show you how to convert your files with sox and how to add them to your MOH classes.