Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript <Embed> Wav File Problem

Status
Not open for further replies.

a012210

Programmer
Jun 21, 2006
5
US
Hey all,

I'm new to the forum and am stumped on a problem with playing a wav file using javascript and the embed tag.

Here are the basic lines of code

function playSound()
{
document.sound1.play();
}

<EMBED SRC="ding.wav" autostart=false HIDDEN=true NAME="sound1" MASTERSOUND>

<input type="button" onclick="playSound()">

When I click the button I get no sound.

The puzzling piece is this: When I change the EMBED tag to HIDDEN=false and then press the button, I get the sound. In other words, when the player is visible on the page, clicking the button works. When it's not visible, clicking the button produces no sound.

Would love to hear your thoughts!

Allen
 
Strange, I tried your code with a .wav file in the same directory and I have no problems in IE6.


[monkey][snake] <.
 
I'm using IE 6.0 on a desktop (everything works)
I'm using IE 6.0 on 2 different laptops (neither works)

 
I'm going to assume you don't have a plug-in installed that allows for that on the laptops that may come installed in the desktop.

[monkey][snake] <.
 
It seems like it's not a plug in or browser issue because
when I use the following embed tag

<EMBED SRC="ding.wav" autostart=false HIDDEN=false NAME="sound1" MASTERSOUND>
the "player" appears on the page and the <input type="button" onClick="playSound()"> plays sound when I click the button.

Again, when I set hidden=true on the embed tag (which hides the player), clicking the button does not produce sound.

When I set hidden=false on the embed tag (which shows the player), clicking the button does produce sound

Note: I'm not clicking anything on the player, only the button which is a separate <input> tag.
 
I have some scripts with embedded sound files that are initiated by an event just like yours. They all worked fine with IE6 and Firefox browsers(last year). Now the scripts no longer work with IE7 or Firefox. I found a site that says that Microsoft made some security updates recently that cause the sounds to no longer work.


If you figure this out please let me know.

Thanks,
vingram
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top