HTML sound options |
HTML sound options |
jmrathbun |
Jun 8 2011, 06:23 PM
Post
#1
|
Newbie Group: Members Posts: 15 Joined: 8-June 11 Member No.: 14,726 |
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.
|
jmrathbun |
Jun 9 2011, 06:59 PM
Post
#2
|
Newbie Group: Members Posts: 15 Joined: 8-June 11 Member No.: 14,726 |
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. 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. |
dojam1 |
Jul 16 2011, 04:03 AM
Post
#3
|
Newbie Group: Members Posts: 11 Joined: 16-July 11 Member No.: 14,949 |
|
jimlongo |
Jul 29 2011, 11:46 PM
Post
#4
|
This is My Life Group: Members Posts: 1,128 Joined: 24-August 06 From: t-dot Member No.: 16 |
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. |
Lo-Fi Version | Time is now: 18th April 2024 - 01:02 PM |