Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Graphics, Flash and Multimedia _ HTML sound options

Posted by: jmrathbun Jun 8 2011, 06:23 PM

What's the best way to code a button that plays a .wav file? What I have now is <A HREF="$sound"><IMG SRC=soundicon.jpg width=50 height=50 alt="PLAY SOUND"> </A> but that loads an ugly new page that the user has to navigate back from and I'd much rather keep it all on the same page if I can.

Posted by: jmrathbun Jun 9 2011, 06:59 PM

Since nobody responded, I did some more research and came up with the following bit of code:

<EMBED ALIGN="CENTER" SRC="$sound" HEIGHT="60" WIDTH="145" AUTOSTART="FALSE" VOLUME="50%" MASTERSOUND ></EMBED>

This produces a little control box that doesn't load a new page when it plays. I'm not sure if the user needs to have something like QuickTime installed for this to work, nor whether it works in all browsers. Anybody up for a little testing?

Interestingly, if you select ALIGN="LEFT" the box will appear to the left of whatever the next line of text may be. For ALIGN="RIGHT" it moves all the way over to the margin. ALIGN="CENTER" positions it on the left margin but above the next line of text. The AUTOSTART tag controls whether the sound starts playing as soon as the page loads (an annoyance for most users, I think).

"$sound" appears in this bit of code because it's part of a CGI script so PERL will load the correct file name, such as "sound1.wav". Substitute your own path to the desired sound file(s) as desired.

I haven't found any good source that documents this bit of code so any expert input will be appreciated.

QUOTE(jmrathbun @ Jun 8 2011, 07:23 PM) *

What's the best way to code a button that plays a .wav file? What I have now is <A HREF="$sound"><IMG SRC=soundicon.jpg width=50 height=50 alt="PLAY SOUND"> </A> but that loads an ugly new page that the user has to navigate back from and I'd much rather keep it all on the same page if I can.


Posted by: dojam1 Jul 16 2011, 04:03 AM

Hope this helps biggrin.gif

http://www.labnol.org/internet/design/html-embed-mp3-songs-podcasts-music-in-blogs-websites/2232/

Posted by: jimlongo Jul 29 2011, 11:46 PM

A lot of it depends on the audio file. Most browsers nowadays will play a lot of audio types natively.

The HTML 5 audio tag http://www.w3schools.com/html5/html5_audio.asp is probably a good way to go, but note that you might need 2 file types to cover all modern browsers.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)