login | register
Sat 19 of Jul, 2008 [23:22 UTC]

voip-info.org

Discuss [6] History

Asterisk cmd MP3Player

Created by: oej,Last modification on Fri 12 of Oct, 2007 [12:39 UTC] by chandave

MP3Player

Synopsis

Plays an MP3 sound file or stream

Description

   MP3Player(location)

Executes the mpg123 unix program to play the given location which typically would either be the filename of an MP3 sound file, or the URL of an MP3 stream. The callers can exit by dialing any digit.

The mpg123 program seems to work best at playing mp3s which do not have any ID3 tag details embedded in them. (Suppressing stderr output fixes the ID3 problem)

Return Codes

Returns -1 on hangup or 0 otherwise.

Example

   MP3Player(/var/lib/asterisk/mohmp3/test.mp3)

Alternative approach

Idea: Implement streaming mp3 as standard music-on-hold.
Question: What happens if the stream is broken, does mpg123 attempt to resume it?

I renamed mpg123 to mpg123.bin and then put this in /usr/local/bin/mpg123. You'll need to restart asterisk in order for this change to take effect.

#!/bin/sh
/usr/bin/mpg123.bin -q -s --mono -r 8000 -f 4096 \
-Z http://66.28.68.70:8005 \
http://66.224.103.98:8930/ \
http://207.200.96.227:8040/


See Also



Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ


Comments

Comments Filter
222

333Using MP3Player from agi with exec

by wonder75, Monday 19 of May, 2008 [22:39:13 UTC]
This gave me a hard time.
When using MP3Player from agi via exec , the right syntax to use is NOT

EXEC MP3Player(file/stream)

it's

EXEC MP3Player file/stream


222

333Asterisk 1.0.7 beta 3 + OS X 10.4.1 + MPG123 0.59r

by henryjunior, Friday 03 of June, 2005 [07:15:15 UTC]
Getting the proper version of MPG123 (v0.59r) setup under OS X was
unusually complicated for me. I finally got the correct file at:

http://www.macupdate.com/info.php/id/6275

What I did was:
(1) First, download the installer at:
http://www.macupdate.com/download.php/6275/mpg123-0.59r.pkg.tgz
(2) un-tar/gzip the resulting file
(3) cntrl+clicked on the resulting 'mpg123-0.59r.pkg' and selected
"Show Package Contents"
(4) navigated to the file 'mpg123'
(5) finally, copied 'mpg123' to the directory /usr/bin/

Apparently, I attempted this with incorrect builds every other time I
tried this 'cuz it didn't work. The good news is now it does (as you can see
I didn't even trust installers this time.) Hope this helps anyone else running Asterisk under OS X.
222

333musiconhold.conf

by hdevito, Thursday 24 of March, 2005 [04:05:47 UTC]
(:confused:)I understand what this is doing, but how do I define musiconhold.conf. What do I need to enter into the conf file? I must be overlooking something.
222

333Streams per caller?

by rustyhodge, Wednesday 16 of March, 2005 [20:48:46 UTC]
Does this open a distinct stream for each caller on hold?
222

333Important end for playing URL

by , Wednesday 05 of January, 2005 [15:12:55 UTC]
Note that it is important to end the 'URL' with a '/', otherwise MP3Player will return with an error.
222

333Play random?

by , Thursday 23 of December, 2004 [15:05:38 UTC]
Any way to play all files within a folder in a random order?