PDA

View Full Version : Play sounds in web page


foxtrot3
04-22-2005, 06:27 AM
I'd like to put a "click to play" link in a web page without having the controller bar show up on a new page. I just want it to play the sound.

When I embed the sound, it works fine, and plays when the page opens, with no controller bar visible.

<embed src="sound.wav" hidden="true" autostart="true">
<noembed><BGSOUND SRC="sound.wav"></noembed>

But I don't want to force the sound, I want to give the viewer the option, ie., click or don't click. But if they do click, I want the sound to play without that freaking controller bar showing up.

I've tried it a bunch of different ways with no luck, basically as follows -

<A HREF="sound.wav" TARGET="_self" HEIGHT="2" WIDTH="2" hidden="true" autoplay="true" controller="false"> Play the Example</A>

I'm very frustrated. Can anybody help with this?

_Aerospace_Eng_
04-22-2005, 07:30 AM
I dont know why you are using the bgsound tag when Internet Explorer is the only browser that supports it. It also supports the embed tag. Try this
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
<!--
function playsong(){
document.getElementById('music').innerHTML='<embed src="http://students.db.erau.edu/~rodri97f/misc/guns.mp3" hidden="true" autostart="true" controls="false">';
}
function stopsong(){
document.getElementById('music').innerHTML='';
}
//-->
</script>
</head>

<body>
<a href="song.wav" onclick="playsong();return false">Play Song</a><br>
<a href="#" onclick="stopsong();return false">Stop Song</a>
<span id="music"></span>
</body>
</html>

foxtrot3
04-23-2005, 04:23 AM
Outstanding!

Many thanks... :thumbsup: