[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

how to use ruby run a mp3 file?

Zhenning Guan

7/29/2007 8:16:00 AM

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
--
Posted via http://www.ruby-....

25 Answers

Chris Lowis

7/29/2007 12:22:00 PM

0

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

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

callme


Chris

--
Posted via http://www.ruby-....

Brett Simmers

7/29/2007 8:39:00 PM

0

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.

Chris Lowis wrote:
> I haven't got a windows system to test this on, but does this work ?
>
> def callme
> system("open 2k7.mp3" )
> end
>
> callme
>
>
> Chris
>
>

Robby Russell

7/29/2007 10:49:00 PM

0

Zhenning Guan wrote:
> 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

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

[1] http://interblah.net/2006/10/4/ajaxworld-pr...
[2] http://rubyu...

Good luck!

Robby



--
Robby Russell
http://www.robbyon...
http://www.planet...

Zhenning Guan

7/30/2007 2:11:00 AM

0

you guy far too kind!
==
system("start XX.mp3")
===

that's ok!

--
Posted via http://www.ruby-....

Adam Akhtar

2/17/2008 4:01:00 PM

0

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)



--
Posted via http://www.ruby-....

Tim Hunter

2/17/2008 6:03:00 PM

0

Adam Akhtar wrote:
> 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)
>
>
>
Do you need to escape those backslashes?

G:\\Itunes etc.

--
RMagick: http://rmagick.ruby...
RMagick 2: http://rmagick.ruby...rmagick2.html

toby.oconnell@gmail.com

2/18/2008 6:20:00 AM

0

On Feb 17, 10:02 am, Tim Hunter <TimHun...@nc.rr.com> wrote:
> Adam Akhtar wrote:
> > 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")
>
>
> Do you need to escape those backslashes?
>
> G:\\Itunes etc.
>
> --
> RMagick:http://rmagick.ruby...
> RMagick 2:http://rmagick.ruby...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"

Adam Akhtar

2/18/2008 1:31:00 PM

0

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


--
Posted via http://www.ruby-....

Jano Svitok

2/18/2008 2:19:00 PM

0

On Feb 17, 2008 5:01 PM, Adam Akhtar <adamtemporary@gmail.com> wrote:
> 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)

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

fedzor

2/20/2008 8:53:00 PM

0

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.