How to use ruby run a mp3 file?

I want to use ruby run excute mp3 file,but I don’t know how to get it
work。
I have a song on D drive and I write a callme.rb
++++++++++
def callme
system(“2k7.mp3” )
end
callme
+++++++++

I am run “ruby callme.rb” in “CMD”
but didn’t run the 2k7.mp3 song
why? how shoud I do it right?

my system is windows XP

I haven’t got a windows system to test this on, but does this work ?

def callme
system(“open 2k7.mp3” )
end

callme

Chris

Almost, on Windows the command is “start”:

def callme
system(“start 2k7.mp3”)
end

callme

That should launch your system’s default mp3 player. I think that will
only work on the native windows build of ruby, not cygwin.

Zhenning G. wrote:

I am run “ruby callme.rb” in “CMD”
but didn’t run the 2k7.mp3 song
why? how shoud I do it right?

my system is windows XP

The Rails plugin, ActsAsHasselhoff[1], provided a way to do this from
within Ruby on Rails. Might be worth looking over the code[2]. :wink:

[1] http://interblah.net/2006/10/4/ajaxworld-presentation
[2] http://rubyurl.com/yrf

Good luck!

Robby

Hi im having a problem playing a song. Im basically got this is my file

system( “start G:\Itunes_To be imported\02 - Anne Clark - The Power
Game.mp3”)

and then running it from within Radrails.

Its keeps complaining “Windows cannot find the file ‘G:\Itunes’…”

What am i doing wrong? (The song definately is in that path as i copied
its path from its properties)

you guy far too kind!

system(“start XX.mp3”)

that’s ok!

On Feb 17, 10:02 am, Tim H. [email protected] wrote:


RMagick:http://rmagick.rubyforge.org/
RMagick 2:http://rmagick.rubyforge.org/rmagick2.html

Or just use single quotes (or %q{start G:\blah.mp3}) rather than
double quotes if you don’t need to interpolate the string. That will
make it easier to read than the extra 's.

irb(main):001:0> %q{start G:\blah.mp3}
=> “start G:\blah.mp3”

ahh yeah i forgot about escaping the backslashes. Ill try both of your
solutions later tonight. thanks very much.

On Feb 17, 2008 5:01 PM, Adam A. [email protected] wrote:

its path from its properties)
I guess you need to quote the file name, i.e.

system( “start "G:\Itunes_To be imported\02 - Anne Clark - The
Power Game.mp3"”)

otherwise the start command considers only the first “word” as the
command to execute,
and the rest are parameters to that command.

Note: due to ****** (censored) design of the start command, any time
you need to quote the command,
you have to add “” in front of it, otherwise the command ends as the
window title. So the final version is:

system( “start "" "G:\Itunes_To be imported\02 - Anne Clark - The
Power Game.mp3"”)

Jano

Anyone know much about ruby-audiere?

Maybe it’s time someone write something like that for multiple OSes.
could probably be easy to do in Rubinius…

ari
--------------------------------------------|
If you’re not living on the edge,
then you’re just wasting space.

Adam A. wrote:

its path from its properties)

Do you need to escape those backslashes?

G:\Itunes etc.