sgreen0
09-05-2002, 12:53 AM
I found this script that I was hoping to use to allow me to include sound clips on demand without embedding a player. I guess it would use whatever player the surfer's browser was configured to use. It works fine in IE6.x (the only version I have right now), but I haven't been able to get it to work in NN6.x. You can test it here (http://www.jacobschimes.com/sound_test.htm).
Is there a better way to do this?
Thanks.
Stephen
<SCRIPT><!--
// MouseOver/MouseClick audio.
// by JS Archive - http://jsarchive.8m.com
var ayAudio = new Array();
// Source for sound files to be preloaded
ayAudio[0] = "clint.wav";
ayAudio[1] = "applause.wav";
ayAudio[2] = "alrighty.wav";
ayAudio[3] = "snore.wav";
ayAudio[4] = "evil-laf.wav";
ayAudio[5] = "frogs.wav";
ayAudio[6] = "giggle.wav";
ayAudio[7] = "organ.wav";
ayAudio[8] = "scream.wav";
function AudioCheck() {
var n = navigator.appName
if (n=="Netscape") this.ns = true;
else if (n=="Microsoft Internet Explorer" && document.all) this.ie = true;
else this.noAudio = true;
}
onload = function() {
is = new AudioCheck()
if (is.noAudio) return;
var s = '';
for (i=0; i<ayAudio.length; i++)
s += "<EMBED SRC='"+ayAudio[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
if (is.ns) {
auEmb = new Layer(0);
with (auEmb.document) { open();write(s);close() };
}
else document.body.insertAdjacentHTML("BeforeEnd",s);
auCon = is.ns? auEmb.document.embeds:auIEEmb;
auCon.ctrl = function(au,play) {
if (is.ie) this.src = play? ayAudio[au]:'';
else eval( "this[au]." + (play? "play()":"stop()") );
}
is.auDone = true;
}
function playAudio(whAu) { if (window.auCon) auCon.ctrl(whAu,1) }
function stopAudio(whAu) { if (window.auCon) auCon.ctrl(whAu,0) }
//--></SCRIPT
Is there a better way to do this?
Thanks.
Stephen
<SCRIPT><!--
// MouseOver/MouseClick audio.
// by JS Archive - http://jsarchive.8m.com
var ayAudio = new Array();
// Source for sound files to be preloaded
ayAudio[0] = "clint.wav";
ayAudio[1] = "applause.wav";
ayAudio[2] = "alrighty.wav";
ayAudio[3] = "snore.wav";
ayAudio[4] = "evil-laf.wav";
ayAudio[5] = "frogs.wav";
ayAudio[6] = "giggle.wav";
ayAudio[7] = "organ.wav";
ayAudio[8] = "scream.wav";
function AudioCheck() {
var n = navigator.appName
if (n=="Netscape") this.ns = true;
else if (n=="Microsoft Internet Explorer" && document.all) this.ie = true;
else this.noAudio = true;
}
onload = function() {
is = new AudioCheck()
if (is.noAudio) return;
var s = '';
for (i=0; i<ayAudio.length; i++)
s += "<EMBED SRC='"+ayAudio[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
if (is.ns) {
auEmb = new Layer(0);
with (auEmb.document) { open();write(s);close() };
}
else document.body.insertAdjacentHTML("BeforeEnd",s);
auCon = is.ns? auEmb.document.embeds:auIEEmb;
auCon.ctrl = function(au,play) {
if (is.ie) this.src = play? ayAudio[au]:'';
else eval( "this[au]." + (play? "play()":"stop()") );
}
is.auDone = true;
}
function playAudio(whAu) { if (window.auCon) auCon.ctrl(whAu,1) }
function stopAudio(whAu) { if (window.auCon) auCon.ctrl(whAu,0) }
//--></SCRIPT