# Help on play a sound

**URL:** <https://www.ruby-forum.com/t/help-on-play-a-sound/183020>\
**Category:** Rails\
**Created:** [February 6, 2010, 8:19am UTC](https://www.ruby-forum.com/t/help-on-play-a-sound/183020 "2010-02-06T08:19:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [February 6, 2010, 8:19am UTC](https://www.ruby-forum.com/t/help-on-play-a-sound/183020/1 "2010-02-06T08:19:04Z")

</div>

Hi…

i have a .wav file in my rails public folder.

i would like to play that file when i click play link in my application.

so i did like below

\<% @file\_path = “#{RAILS\_ROOT}” +  
“/public/Server\_exe/#{voicemail.file\_path}” %\>

\<%if File.exists?("#{@file\_path}")%\>

```
<%= link_to image_tag("configure.png",:title =>

```

“play”),"/Server\_exe/#{voicemail.file\_path}" %\>

\<%end%\>

this code simply opens the file , and the firefox browser asks me  
whether to open the file in windows media player?

if i click yes , browser opens the file and again i should click the  
play button of windows meadia player…

Is there any way to play that file simply when click the play link from  
my rails application?

Thanks for your time.

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [February 6, 2010, 8:43pm UTC](https://www.ruby-forum.com/t/help-on-play-a-sound/183020/2 "2010-02-06T20:43:22Z")

</div>

On Feb 6, 2:19 am, Newb N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi…
> 
> i have a .wav file in my rails public folder.
> 
> i would like to play that file when i click play link in my application.

[snip]

> Is there any way to play that file simply when click the play link from  
> my rails application?

Your best bet is probably some kind of Flash player, that you feed the  
URL to in the embed/object tag. At some point in the future, you’ll be  
able to play the file natively with HTML5, but that’s not yet.

Oh, and you’ll want to get some kind of audio compression going -  
neither your users nor your host are going to like downloading  
uncompressed .wav files…

–Matt J.

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [February 6, 2010, 9:50pm UTC](https://www.ruby-forum.com/t/help-on-play-a-sound/183020/3 "2010-02-06T21:50:06Z")

</div>

Sent from my iPhone

On Feb 6, 2010, at 11:41 AM, Matt J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [snip]  
> Oh, and you’ll want to get some kind of audio compression going -  
> neither your users nor your host are going to like downloading  
> uncompressed .wav files…
> 
> –Matt J.

If you’re using a browser that supports HTML 5 (i.e. Safari 4,  
Firefox 3.6, Chrome, or Opera), you can use the tag today.  
Also, you might want to covert your .wav file to .mp3.

Good luck,

-Conrad

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [February 6, 2010, 9:54pm UTC](https://www.ruby-forum.com/t/help-on-play-a-sound/183020/4 "2010-02-06T21:54:47Z")

</div>

Most any audio file will play in the browser via an HREF link. Just  
link to the file. This has nothing to do with rails. It’s basic HTML.  
You don’t even need html5.

Converting to mp3 would be a good idea for compatability and smart  
downloads.

-j

Sent from my iPhone

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [February 6, 2010, 10:34pm UTC](https://www.ruby-forum.com/t/help-on-play-a-sound/183020/5 "2010-02-06T22:34:43Z")

</div>

John Adams wrote:

> Most any audio file will play in the browser via an HREF link. Just  
> link to the file. This has nothing to do with rails.

Right.

> It’s basic HTML.

No, it’s not basic HTML. Sure, you can link to an audio file or  
anything else, but it’s up to the browser to figure out what to do with  
it – which puts the OP right back at square one.

> You don’t even need html5.
> 
> Converting to mp3 would be a good idea for compatability and smart  
> downloads.

Yup.

> -j
> 
> Sent from my iPhone

Best,  
–Â  
Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
