Hi just a quick question in regards to the music on hold. i am using a mysql table musiconhold which have a field directory and application. currently i use local file to be played in the music on hold, is there anyway i can use remote file which is available on mp3 format.
can anyone please guide what will be the value in the directory and application field? i assume mode will be custom.
For this, you will have to rely on an external program/script, I don’t know of any other way to do this using musiconhold.conf directly. An in-house solution we use is a bash script that acts as a wrapper for ffmpeg. This way, we can play anything as moh, just by passing it with a link or file.
[remote]
mode = custom
application=/my/script/path <filename.mp3 or https://link.com/filename.mp3>
This will cause Asterisk to execute our script, which will then take care of the logic of retrieving and converting the files with ffmpeg, sending output to stdout, and already in the format that Asterisk expects. This script I showed you is just an example, but you can do much more exotic things with a little creativity and a few tricks.
Oh, and spoiler alert! This has served us for years, across multiple installations, and with almost no problems.
Thank you so much, Let me check it out. but i have tried to put application = /usr/bin/mpg123 -y -q -s --mono -r 8000 -f 8192 -b 2048 -s https://storage.googleapis.com/xxx.mp3 and it did not work. asterisk is showing warning WARNING[790]: res_musiconhold.c:811 monmp3thread: poll() failed: Interrupted system call
mpg123 still supports http in versions beyond 1.30; I have 1.33.2 and I am able to play back files over https or http.
Usually the monmp3thread error happens when the application being called isn’t sending data. Your command looks fine and should be sending data Asterisk likes without any special handling. This command is very similar to what I use for my icecast streams; and they work with mpg123 (and ogg123 too).
My guess is it’s taking mpg123 too long to start sending data due to the fact the file is “really remote” and asterisk gets angry. If you can replace the URL with a local file and it works; then this is the only thing I can think of.