I realise that this post I’m replying to is a little old, but I thought having finally “cracked it”, I might as well post what I’ve done.
https://github.com/lardconcepts/asterisk-digitalocean-voipfone-config/blob/master/moh-switching.md
Can someone please take a quick look and see if there’s anything I could
have done better or more efficiently, or if anything stands out as
particularly horrific?
Basically, it uses an app called crudini to add sections to
musiconhold.conf, then does an moh reload.
When the user has finished listening and presses * then the remote
extension is dropped and the caller returns to the current menu.
The nice thing about this is that even if two callers call and listen to
the same moh stream, when one hangs up, even though it deletes the config
and reloads moh, Asterisk is nice to the other caller and they keep
listening.
The end result is what I wanted, which is to not have any extra CPU load or
network usage when no-one is listening. And if more than one person is
listening, it’s still only “using” one remote stream, as I’ve uncommented
the cachertclasses value.
[general]
cachertclasses=yes ; use 1 instance of moh class for all users who are using it
As a little bonus, I’ve put what I think is a clever little "menu maker"
in, which grabs and caches short audio files using the free plan from
voicerss.org.
If anyone wants to try it in practice, call UK +44 20 36 37 60 70 - this
number is working as of now and I’ll leave it up as long as I can, but if you’re reading this in a few weeks, don’t expect
it to work! (I’m allowed to use these streams before anyone panics!).