PDA

View Full Version : sound and mimeTypes


Alias
05-04-2003, 06:06 PM
Hello folks

This is my solution for development of sound in html:

<script language="JavaScript"><!--
var aySound = new Array();
aySound[0] = "websound.wav";

var navA=navigator.userAgent;
var op=(navA.indexOf("Opera")>-1 && dom);

if (document.all && !op)
document.write('<bgsound src="#" id="bgmusic" loop="infinite" autostart="true">');
else
document.write('<embed src="websound.wav" name="embmusic" hidden="true" autostart="false" loop="true" MASTERSOUND></embed>');

//-->
</script>



<script language="JavaScript">

var navA=navigator.userAgent;
var op=(navA.indexOf("Opera")>-1 && dom);

function stopp() {
if (document.all && !op) {
document.execCommand('Stop');
}
else {
document.embmusic.stop();
}
}

function playmusic() {
if (document.all && !op) {
document.all.bgmusic.src='websound.wav';
}


else {
if (navigator.mimeTypes["audio/x-wav"]) {
document.embmusic.play();
}
else {
if (confirm("AUDIO PLUGIN NOT FOUND. \n\nTo listen to the music from this website you need to \ndownload and install audio plugin for your browser. \n\n\nDo you want to download it now? \nhttp://plugins.netscape.com"))
window.open("http://plugins.netscape.com","_blank")
}
}
}
</script>

<a href="javascript:stopp();">stop</a> <a href="javascript:playmusic();">play</a>
(note: onclick="stopp();" for IE 4.0 doesn't work! - must be - href="javascript:stopp();") (???)

This works fine in IE 4.0 +, Netscape 4.07 and Netscape 4.6 (where to download version 4.7?)
but it not works for Netscape 6.0, Netscape 7.02 and Mozila 1.0 + ...
well, I know that I don't have a plugins for NS 6.0 and 7.0 ... it's ok ...
My problem and question is -
to leave this:

if (navigator.mimeTypes["audio/x-wav"] || navigator.mimeTypes["audio/wav"])

or to remove it ?


What is your opinion about all this approach ...

Best Regards

agent002
05-05-2003, 05:15 AM
At least to the question why <a onclick="">Link</a> doesn't work in IE, is probably since there's no value for "href". You could use
<a href="#" onclick="stopp();">Stop</a>,
maybe that works?

Alias
05-05-2003, 10:48 AM
Hello Agent002,

thanx for reply ;)

<a href="javascript:;" onclick="stopp();">Stop</a>,
also don't works but
<a href="java script:stopp();">stop</a>
work just fine for all IE versions ...

but what you think about:
if (navigator.mimeTypes["audio/x-wav"] || navigator.mimeTypes["audio/wav"])

Can somebody to have some plugin wich can play my script and to not have audio/x-wav or audio/wav ?
(ofcourse only for browsers different from IE)

Best Regards
(sorry for my english)