how do I play mp3 file?

Bhushan Lodha picture Bhushan Lodha · Mar 27, 2012 · Viewed 9k times · Source

How can I write a script in ruby which plays mp3 file (background-music) when executed from command-line?

I tried this

run = "mplayer #{"/Users/bhushan/resume/m.mp3"} -ao sdl -vo x11 -framedrop -cache 16384 -cache-min 20/100"
system(run)

but it is not working also, above is player specific. what if user don't have mplayer installed. Id there a better way?

Answer

nex picture nex · Jun 10, 2012

I usually just do

pid = fork{ exec 'mpg123','-q', file }