Forum: Ruby how to use ruby run a mp3 file?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ffd881829651935d986c52d12279befb?d=identicon&s=25 Zhenning Guan (rubyernewbie)
on 2007-07-29 10:16
I want to use ruby run excute mp3 file,but I don't know how to get it
I have a song on D drive and I write a callme.rb
def callme
 system("2k7.mp3" )

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
A8486651a974d7d9ecc35d25de96c7ee?d=identicon&s=25 Chris Lowis (chrislo)
on 2007-07-29 14:21
I haven't got a windows system to test this on, but does this work ?

 def callme
  system("open 2k7.mp3" )


D046d3c8b40b45f19044671cf6cf40f9?d=identicon&s=25 Brett Simmers (Guest)
on 2007-07-29 22:40
(Received via mailing list)
Almost, on Windows the command is "start":

def callme
  system("start 2k7.mp3")


That should launch your system's default mp3 player.  I think that will
only work on the native windows build of ruby, not cygwin.
B84d42a3a5c343f8fc6ab7d7f47fd3f5?d=identicon&s=25 Robby Russell (Guest)
on 2007-07-30 00:49
(Received via mailing list)
Zhenning Guan 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]. ;-)


Good luck!

Ffd881829651935d986c52d12279befb?d=identicon&s=25 Zhenning Guan (rubyernewbie)
on 2007-07-30 04:10
you guy far too kind!
system("start XX.mp3")

that's ok!
803ad415efcdcbf09b1addeb319650d7?d=identicon&s=25 Adam Akhtar (thegeezer3)
on 2008-02-17 17:01
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

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)
3afd3e5e05dc9310c89aa5762cc8dd1d?d=identicon&s=25 Tim Hunter (Guest)
on 2008-02-17 19:03
(Received via mailing list)
Adam Akhtar wrote:
> its path from its properties)
Do you need to escape those backslashes?

G:\\Itunes etc.
Ad0352f10cdf13c1c0e90e1d78f9f603?d=identicon&s=25 (Guest)
on 2008-02-18 07:25
(Received via mailing list)
On Feb 17, 10:02 am, Tim Hunter <> wrote:
> --
> RMagick:
> RMagick 2:

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"
803ad415efcdcbf09b1addeb319650d7?d=identicon&s=25 Adam Akhtar (thegeezer3)
on 2008-02-18 14:31
ahh yeah i forgot about escaping the backslashes. Ill try both of your
solutions later tonight. thanks very much.
97550977337c9f0a0e1a9553e55bfaa0?d=identicon&s=25 Jano Svitok (Guest)
on 2008-02-18 15:20
(Received via mailing list)
On Feb 17, 2008 5:01 PM, Adam Akhtar <> 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\"")

Dec001d46d9ccb152be2f2c8a143934d?d=identicon&s=25 fedzor (Guest)
on 2008-02-20 21:53
(Received via mailing list)
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...

If you're not living on the edge,
then you're just wasting space.
This topic is locked and can not be replied to.