Asterisk cmd MP3Player
MP3Player
Synopsis
Plays an MP3 sound file or streamDescription
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
- MusicOnHold
- Using Slimserver for playing MOH
- Playback: Play a sound file
- Background: Play a sound file while processing other commands
- Playtones: Play a tone sequence
- Sound Files
Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ


Comments
333Using MP3Player from agi with exec
When using MP3Player from agi via exec , the right syntax to use is NOT
EXEC MP3Player(file/stream)
it's
EXEC MP3Player file/stream
333Asterisk 1.0.7 beta 3 + OS X 10.4.1 + MPG123 0.59r
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.
333musiconhold.conf
333Streams per caller?
333Important end for playing URL
333Play random?