Asterisk cmd MP3Player

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.

Examples

Example 1

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

Example 2

I managed to run internet radio (that streams MP3) within asterisk.
Minor change is nescesarry to make it work with random MP3s.

My dialplan:

exten => _X.,n,Answer()
exten => _X.,n,MP3Player(http://stream.m-1.fm/m1/mp3)

$ cat /usr/bin/mpg123:

  1. !/bin/bash
/usr/bin/wget -q -O - $1 | /usr/bin/madplay -Q -z -o raw:- --mono -R
8000 -a -6 -

You should change the WGET part to something that better suits your needs.

Tested on asterisk 1.4.27

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.

  1. !/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

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.

Examples

Example 1

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

Example 2

I managed to run internet radio (that streams MP3) within asterisk.
Minor change is nescesarry to make it work with random MP3s.

My dialplan:

exten => _X.,n,Answer()
exten => _X.,n,MP3Player(http://stream.m-1.fm/m1/mp3)

$ cat /usr/bin/mpg123:

  1. !/bin/bash
/usr/bin/wget -q -O - $1 | /usr/bin/madplay -Q -z -o raw:- --mono -R
8000 -a -6 -

You should change the WGET part to something that better suits your needs.

Tested on asterisk 1.4.27

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.

  1. !/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

Created by: oej, Last modification: Fri 30 of Apr, 2010 (11:55 UTC) by JustRumours
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+