Play specific file with StartMusicOnHold instead of files on folder

Hi! I’ve been researching to solve this for about a week but can’t find a solution.
I’m using eagi with node and i want to play different specific files in a certain point of the script execution.
I need to play the file without blocking the script, so StartMusicOnHold is the only application which doesn’t block the execution, I’ve tried Playback, Background and MusicOnHold but they don’t work for my purpose since I want to be able to stop playing the audio aswell.

I’ve tried to create a custom class on musiconhold.conf and use mpg123 to play a given audio file, but it just plays in loop and I can’t specify any other file. I could create many different classes with different folders containing a single file which would be the one i’d like to play but sometimes i get the file and write it to disk during the script execution, so it’s a half-way workaround.

Can someone help me or give me some ideas? I’m kind of stuck. I’ve also though about creating a custom C app using StartMusicOnHold as reference but don’t know where to start since Asterisk it’s kind of big.

Thanks.

The MOH module isn’t written to operate on single files but a directory of files as you’ve mentioned. There’s no real way to overcome that except a folder per file, or modifying the source code. The MOH source code itself is res_musiconhold.c in the res directory.

1 Like