From 1c539e6982b519a38ae1da2ce54b222e5233db2f Mon Sep 17 00:00:00 2001 From: David Vossel Date: Fri, 4 Dec 2009 20:19:53 +0000 Subject: .m3u support for Mp3Player app (closes issue #14823) Reported by: macli Patches: app_mp3.diff1 uploaded by macli (license ) Tested by: macli, dvossel git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@233234 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_mp3.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'apps') diff --git a/apps/app_mp3.c b/apps/app_mp3.c index b177fb027..b2163070a 100644 --- a/apps/app_mp3.c +++ b/apps/app_mp3.c @@ -21,6 +21,9 @@ * \brief Silly application to play an MP3 file -- uses mpg123 * * \author Mark Spencer + * + * \note Add feature to play local M3U playlist file + * Vincent Li * * \ingroup applications */ @@ -47,7 +50,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") /*** DOCUMENTATION - Play an MP3 file or stream. + Play an MP3 file or M3U playlist file or stream. @@ -56,7 +59,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") - Executes mpg123 to play the given location, which typically would be a filename or a URL. + Executes mpg123 to play the given location, which typically would be a mp3 filename + or m3u playlist filename or a URL. Please read http://en.wikipedia.org/wiki/M3U + to see how M3U playlist file format is like, Example usage would be + exten => 1234,1,MP3Player(/var/lib/asterisk/playlist.m3u) User can exit by pressing any key on the dialpad, or by hanging up. @@ -89,6 +95,14 @@ static int mp3play(const char *filename, int fd) /* 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 if (strstr(filename, ".m3u")) { + /* Most commonly installed in /usr/local/bin */ + execl(LOCAL_MPG_123, "mpg123", "-q", "-z", "-s", "-b", "1024", "-f", "8192", "--mono", "-r", "8000", "-@", filename, (char *)NULL); + /* But many places has it in /usr/bin */ + execl(MPG_123, "mpg123", "-q", "-z", "-s", "-b", "1024","-f", "8192", "--mono", "-r", "8000", "-@", filename, (char *)NULL); + /* As a last-ditch effort, try to use PATH */ + execlp("mpg123", "mpg123", "-q", "-z", "-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); -- cgit v1.2.3