Playing MP3's through rails?

I have been trying to figure out the best way to serve music mp3’s
from my web server in Rails.
If I do mysite.com/audio/mysong.mp3 it seems to play the song, but
sometimes a dialog comes up asking if you want to save the file when
the user clicks the link. That depends on the browser.
I don’t want to do that, I just want the song to play.

If I set up a partial template like below. That seems to work on the
first load. But when I render the partial a second time with a
different song. The first song is still playing and the new song
starts playing as well so there are 2 songs playing at the same time.
I’ve looked into how to do send_file()/send_data() and so on, not sure
on that, but I suspect it may work the same as the other method
above ? for that I found this, but I haven’t figured it out: http://
http://www.ruby-forum.com/topic/61437

Here’s the templat I have that is partialy rendered:

<EMBED SRC=<%="‘/audio/#{@song}’ HIDDEN AUTOSTART=‘TRUE’ LOOP=‘FALSE’
WIDTH=‘0’ HEIGHT=‘0’ CONTROLLER=‘FALSE’ " %>

BGCOLOR=‘#FF9900’>

While I’m at it, is there any way to have an mp3 keep playing a song
when you render a new page ?

Thanks

i havent tried it, but check out this?

http://www.agilewebdevelopment.com/plugins/flash_mp3_image_media_flv_player

For God’s [and the user’s] sake, please don’t play media on the user’s
computer without the user’s explicit request. Remember the mid-late 90’s
midi embedded web sites? Oh, the nightmares this is gonna give me.

RSL

On 2/9/07, Russell N. [email protected] wrote:

For God’s [and the user’s] sake, please don’t play media on the user’s
computer without the user’s explicit request. Remember the mid-late 90’s
midi embedded web sites? Oh, the nightmares this is gonna give me.

RSL

I don’t want to do that, I just want the song to play.
Here’s the templat I have that is partialy rendered:

I somewhat agree with Russell on this, however for some sites it can
make
sense to do this.

The issue isn’t specific to Rails, you would use the same techniques as
elsewhere. For instance you can have a frame that stays active or you
can of
course pop a new window to hold this. Either of those methods would
allow
you to continue playing between page transitions. Both have their own
disadvantages (framesets and popup windows blocking).

Remember to provide an option for users to silence the sound and note
that
many users might visit your site at work (where sound isn’t necessarily
a
desirable thing). It is so frustrating when sites don’t give you the
option
of turning that off.

Blessings,

Jeff


Jeff B., MasterView core team
Inspired Horizons Ruby on Rails Training and Consultancy
Next Ruby on Rails plus JRuby workshop Feb 22-24 St. Louis, MO
http://inspiredhorizons.com/training/rails/index.html
Limited seating, register now!

You’ll need to use a player to play the file. Your best bet is one
constructed in flash. Then you can give the user controls for muting
audio
or adjusting volume.

M<><

On Feb 9, 6:37 am, koloa [email protected] wrote:

i havent tried it, but check out this?

http://www.agilewebdevelopment.com/plugins/flash_mp3_image_media_flv_


Posted viahttp://www.ruby-forum.com/.

Thanks,

I’ve played around with this and have had a number of problems with
firefox as well as other issues.
It does look interesting, but my song will also show up in the html,
so it doesn’t prevent anyone from stealing the music any different if
I used some other method I’m guessing. At this time I am probably
going to try a simpler approach for now I guess.