Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Play audio files from Perl scripts on Linux (high level audio playing)

Status
Not open for further replies.

Kirsle

Programmer
Jan 21, 2006
1,179
US
This is a follow-up to my previous thread about this, thread219-1355244, which is closed now.

I was wondering if there was an easy way to just play an audio file in Linux from a Perl script, in a way equivalent to Win32::MediaPlayer for Windows.

Last night I was investigating audio libraries and saw a mention of GStreamer, which I had heard of but didn't realize there was an actual library to it, so I searched CPAN to see if somebody had ported GStreamer to Perl. They have.

So, using the GStreamer module, you can get high-level audio access from a Perl script. It's not quite as simple to use as Win32::MediaPlayer and it seems to require a full absolute path to the media file to play, but it's still pretty cool. It comes with an example script "player.pl" that plays any audio file that GStreamer has support for (i.e. if ya install all the "gstreamer-plugin-*" from your friendly neighborhood software repository, your Perl scripts should be able to play pretty much any audio file, just like Win32::MediaPlayer).

Just thought I'd share. You could of course use SDL::Sound for cross-platform sound support but iirc SDL::Sound only has support for a small range of audio formats.

-------------
Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top