A
Asterbing
Hello,
Here is a page which contains an "evoluated" (to distinguish-it from the
simple one) way to hear sound on a html page event. From my memory, it
worked under all major browsers, but didn't succeed these last days.
I've just tried it today under IE6, Netscape 7, Mozilla 7 and Opera 1.6.
And it only works under IE.
Could you try, please. Is it the same for you ?
Here is the entire HTML file :
------------------------------
<html>
<head>
<!-- SOUND CODE (for évoluated way)
NB : not in external .js due to pb on insertAdjacentHTML -->
<script type="text/javascript" language="JavaScript"><!--
var arPreloadSounds = new Array();
arPreloadSounds[0] = "sound.wav"; // sounds to preload :
document.write('<BGSOUND ID="auIEContainer">');
var IE=(navigator.appVersion.indexOf("MSIE")!=-1 && document.all)?1:0;
var NS=(navigator.appName=="Netscape"&&navigator.plugins["LiveAudio"])?
1:0;
var ver4 = IE||NS? 1:0;
function PreloadSounds()
{
var Str;
if (!ver4)
return;
if (NS)
{
auEmb = new Layer(0,window);
}
else
{
Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
document.body.insertAdjacentHTML("BeforeEnd",Str);
}
Str = '';
for (i=0; i<arPreloadSounds.length; i++)
Str += "<EMBED SRC='" + arPreloadSounds + "'
AUTOSTART='FALSE' HIDDEN='TRUE'>";
if (IE)
{
auEmb.innerHTML = Str;
}
else
{
auEmb.document.open();
auEmb.document.write(Str);
auEmb.document.close();
}
auCon = IE? document.all.auIEContainer:auEmb;
auCon.control = AudioControl;
}
function AudioControl(whSound,play)
{
if (IE)
this.src = play? arPreloadSounds[whSound]:'';
else
eval("this.document.embeds[whSound]." + (play? "play
()":"stop()"));
}
function PlaySound(whSound)
{
if (window.auCon)
auCon.control(whSound,true);
}
function StopSound(whSound)
{
if (window.auCon)
auCon.control(whSound,false);
}
//--></script>
</head>
<body>
<!-- SIMPLE WAY (IE ONLY) -->
<bgsound id=music loop=1 autostart="false">
<a href="#" onMouseOver="document.all.music.src='sound.wav'">SIMPLE WAY
</a><p>
<!-- EVOLUATED WAY (CROSS-BROWSER CONSIDERATION)
***TODO : doesn't seems to work under NN7, Mozilla 7 and Opera 1.6
???
-->
<a href="#" onMouseOver="PlaySound(0);">EVOLUATED WAY</a><p>
</body>
</html>
Here is a page which contains an "evoluated" (to distinguish-it from the
simple one) way to hear sound on a html page event. From my memory, it
worked under all major browsers, but didn't succeed these last days.
I've just tried it today under IE6, Netscape 7, Mozilla 7 and Opera 1.6.
And it only works under IE.
Could you try, please. Is it the same for you ?
Here is the entire HTML file :
------------------------------
<html>
<head>
<!-- SOUND CODE (for évoluated way)
NB : not in external .js due to pb on insertAdjacentHTML -->
<script type="text/javascript" language="JavaScript"><!--
var arPreloadSounds = new Array();
arPreloadSounds[0] = "sound.wav"; // sounds to preload :
document.write('<BGSOUND ID="auIEContainer">');
var IE=(navigator.appVersion.indexOf("MSIE")!=-1 && document.all)?1:0;
var NS=(navigator.appName=="Netscape"&&navigator.plugins["LiveAudio"])?
1:0;
var ver4 = IE||NS? 1:0;
function PreloadSounds()
{
var Str;
if (!ver4)
return;
if (NS)
{
auEmb = new Layer(0,window);
}
else
{
Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
document.body.insertAdjacentHTML("BeforeEnd",Str);
}
Str = '';
for (i=0; i<arPreloadSounds.length; i++)
Str += "<EMBED SRC='" + arPreloadSounds + "'
AUTOSTART='FALSE' HIDDEN='TRUE'>";
if (IE)
{
auEmb.innerHTML = Str;
}
else
{
auEmb.document.open();
auEmb.document.write(Str);
auEmb.document.close();
}
auCon = IE? document.all.auIEContainer:auEmb;
auCon.control = AudioControl;
}
function AudioControl(whSound,play)
{
if (IE)
this.src = play? arPreloadSounds[whSound]:'';
else
eval("this.document.embeds[whSound]." + (play? "play
()":"stop()"));
}
function PlaySound(whSound)
{
if (window.auCon)
auCon.control(whSound,true);
}
function StopSound(whSound)
{
if (window.auCon)
auCon.control(whSound,false);
}
//--></script>
</head>
<body>
<!-- SIMPLE WAY (IE ONLY) -->
<bgsound id=music loop=1 autostart="false">
<a href="#" onMouseOver="document.all.music.src='sound.wav'">SIMPLE WAY
</a><p>
<!-- EVOLUATED WAY (CROSS-BROWSER CONSIDERATION)
***TODO : doesn't seems to work under NN7, Mozilla 7 and Opera 1.6
???
-->
<a href="#" onMouseOver="PlaySound(0);">EVOLUATED WAY</a><p>
</body>
</html>