Reading dtmf while playing an mp3 file through MP3Player

Can any body tell me how to input a key while playing a file through MP3Player application.
Just like the Background application does


show file formats
on the asterisk CLI.
See if mp3 is mentioned along with others.
If yes then you can stream mp3.

Just give the filepath without the mp3 extension in Background.
You can also use the ‘mp3player’ application that can stream from a URL.

show application mp3player
on the asterisk CLI

search for mp3player in

In future post such questions in the user section

This IS a developers question.
I am trying to play an mp3 file for my own IVR application. I am executing the MP3Player application using the asterisk’s pbx_exec() function. The application returns when the user presses a key, but how can I fetch that key?? I’ve tried the ast_readstring() function but the user has to press the key twice. (Once to exit MP3Player and then again for ast_readstring)

I don’t get mp3 with the ‘show file formats’ command. I am using asterisk-1.0.9.

have you installed mpg123 or mpg321 … +MP3Player

yes. Infact the mp3 file is playing fine. I am having problems with getting the digit pressed during the playing of the file.

Have you tried the above with ‘Background’ application.

I tried to play the file with Background. The following message appeared:

format_wav.c:111 check_header: Does not begin with RIFF

using asterisk 1.2.10 and the Background application streams mp3

recompiling with the recent app_mp3.c may help for the mp3player.
try and see

code from app_mp3.c that exits playing on DTMF

					if (f->frametype == AST_FRAME_DTMF) {
						ast_log(LOG_DEBUG, "User pressed a key\n");
						res = 0;

Do you have it in your version

screw all of that, use the Read command to stream the file, and it will be able to pick up the keypress.

exten => s,1,Read(variable[|filename][|maxdigits][|option])

variable is the whatever you want - it will hold the captured digits.

filename is the mp3 you want to play.

maxdigits will allow you to set how many digits you want to capture.

leave option blank - that would normally be for a timeout, but you’ll be playing a longer song…

otherwise, if you wanted to use Background, set up a context like so:

exten => s,1,Background(mp3file)
exten => _X,1,dowhateveryouneed

that SHOULD allow you to capture a single digit press (1-9) and route based on that…the only hitch is that you need to set this up in it’s own context, but Goto makes that pretty easy…

EDIT: this belongs in the users section.

If background cannot stream mp3 in his case [asterisk-1.0.9] how will he use read?[/code]

oh, didn’t realize he was still on 1.0.9

any chance you can upgrade to the 1.2 branch? native file streaming works SO much better in the newer branch.

i wouldn’t even mess with MP3’s in the older verions, because you have to rely on mpg123, which is a (no offense to the developers) a peice of garbage.

that’s my $0.03, sorry i didn’t catch that before.

using asterisk 1.2.10 but the mp3player code in app_mp3.c uses mpg123

/* Execute mpg123, but buffer if it's a net connection */
if (!strncasecmp(filename, "http://", 7)) {
	/* Most commonly installed in /usr/local/bin */
    execl(LOCAL_MPG_123, "mpg123", "-q", "-s", "-b", "1024", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
	/* But many places has it in /usr/bin */
    execl(MPG_123, "mpg123", "-q", "-s", "-b", "1024","-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
	/* As a last-ditch effort, try to use PATH */
    execlp("mpg123", "mpg123", "-q", "-s", "-b", "1024",  "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
else {
	/* Most commonly installed in /usr/local/bin */
    execl(MPG_123, "mpg123", "-q", "-s", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
	/* But many places has it in /usr/bin */
    execl(LOCAL_MPG_123, "mpg123", "-q", "-s", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);
	/* As a last-ditch effort, try to use PATH */
    execlp("mpg123", "mpg123", "-q", "-s", "-f", "8192", "--mono", "-r", "8000", filename, (char *)NULL);


I don’t think they have removed mpg123 support?