tags:

views:

313

answers:

3

I need to play, pause and resume AAC (audio) 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).

A: 

I've never done it or tried, you can script itunes from the command line http://www.macosxhints.com/article.php?story=20011108211802830 which can definitely handle AAC files. You can use ruby to call the command line using back quotes ls -a what is your use case, why do you want to do this?

ThinkBohemian
Ack, I don't want iTunes popping up, In fact, I don't want iTunes loaded at all. Its a console (curses) based iTunes alternative. I want to read up my iTunes directory, allow me to select and play/pause, and see some basic info of each mp3/aac file.I wish to use the rbcurse toolkit and build a simple console music player with vim like bindings (which rbcurse provides already in some cases). More for learning than anything.
rahul
A: 

If you're making this program for a Mac OS based console, check out the afplay system utility. It'll handle anything CoreAudio/Quicktime can.

Also of note are the related utilities afconvert, afinfo, all of which are standard in Mac 10.6.x. They may exist in earlier versions of the Mac OS, but I can't really verify that.

Damien Wilson
Thanks. afplay looks interesting. But it does not provide ability to *pause* and *resume*. Although, I am on OS X, however, being a ruby curses application, people on linux should be able to use it too. Pause and resume is important. I think afplay does allow changing volume in between which is required.
rahul
A: 

Have you seen RubyGame? It has a Music class that can play, pause/unpause, stop, rewind, jump to another time, adjust volume and fade out

It uses Ruby-SDL-FFI to provide SDL access from Ruby

SDL provides the low level access to the audio and is cross-platform

Timberford