Play audio file (AAC) from ruby program

I need to play, pause and resume AAC files from a ruby console program
(much like iTunes or any music player).

After much searching, I’ve come across these libraries:

  1. mp3info
  2. metadata
  3. id3lib-ruby
  4. rvideo (uses ffmpeg)

These seem to help me in getting track length and tags which i also
need, but I need something to play AAC (at least) and if possible other
formats. I also must be able to pause and resume (so shelling a program
like mpg321 is out).

On Fri, May 14, 2010 at 10:26 AM, Louis-Philippe [email protected]
wrote:

  1. metadata
  2. id3lib-ruby
  3. rvideo (uses ffmpeg)

These seem to help me in getting track length and tags which i also
need, but I need something to play AAC (at least) and if possible other
formats. I also must be able to pause and resume (so shelling a program
like mpg321 is out).

I’m not saying it’s the best solution, but you can use mpg321 to
pause and resume. I think you need to use -R

if its for the mac, you could use MacRuby with QTKit.

2010/5/14 R. Kumar [email protected]

Luis P. wrote:

These seem to help me in getting track length and tags which i also
need, but I need something to play AAC (at least) and if possible other
formats. I also must be able to pause and resume (so shelling a program
like mpg321 is out).

I’m not saying it’s the best solution, but you can use mpg321 to
pause and resume. I think you need to use -R

Thanks, I just tried it. It gave a malloc error complaining first that
it could only do 44Khz files. (Crashed out on LOAD).

Thanks, I just tried it. It gave a malloc error complaining first that
it could only do 44Khz files. (Crashed out on LOAD).

You might also try mplayer in -slave mode. I know that can handle 48k
audio.

-Jonathan N.

Louis-Philippe wrote:

if its for the mac, you could use MacRuby with QTKit.

I am on a mac, but this is a console program so should be usable on
other systems too. Also, Macruby makes it a GUI program, I am using a
character terminal.

I’ve come across a Snack Sound Toolkit,
Snack Sound Toolkit - Wikipedia – seems to be some
ancient bindings to it, less than alpha and untested. It also requires
Tk.

portaudio has some ruby bindings to it: paruby and ruby-portaudio
(ruby-portaudio/lib/portaudio.rb at master · jvoorhis/ruby-portaudio · GitHub).
The latter is Feb 2010 the other (paruby) seems quite old and perhaps
abandoned (updated 2006, status: in development).

Someone suggested “afplay” – this is a command line utility on OSX.
Unfortunately, does not allow me to pause resume.

So it looks like ruby-portaudio may be the best bet at present.