Foros del Web » Programando para Internet » Javascript »

Sonidos...!!!

Estas en el tema de Sonidos...!!! en el foro de Javascript en Foros del Web. Hola: Estoy haciendo una página WEB, pero le estoy metiendo sonido a unos botones, para cuando pasen el mouse por encima de ellos se oiga ...
  #1 (permalink)  
Antiguo 25/11/2002, 19:26
 
Fecha de Ingreso: noviembre-2002
Mensajes: 24
Antigüedad: 21 años, 5 meses
Puntos: 0
Sonidos...!!!

Hola:

Estoy haciendo una página WEB, pero le estoy metiendo sonido a unos botones, para cuando pasen el mouse por encima de ellos se oiga con voz el nombre del boton. En Dreamweaver hici esto, pero en mi computadora, si funciona... pero en otras computadoras cuando pasan el mouse por encima del boton, se abre el Media Player para oir el sonido o el Quick Time. Este es el codigo que genero Dreamweaver... Que es lo que tengo que hacer... para que funcione en todas las computadoras sin que se tenga que abrir otro programa para oir el sonido...? de antemano gracias por su comentarios...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_controlSound(x, _sndObj, sndFile) { //v3.0
var i, method = "", sndObj = eval(_sndObj);
if (sndObj != null) {
if (navigator.appName == 'Netscape') method = "play";
else {
if (window.MM_WMP == null) {
window.MM_WMP = false;
for(i in sndObj) if (i == "ActiveMovie") {
window.MM_WMP = true; break;
} }
if (window.MM_WMP) method = "play";
else if (sndObj.FileName) method = "run";
} }
if (method) eval(_sndObj+"."+method+"()");
else window.location = sndFile;
}
//-->
</script>
</head>

<body>
<div id="Layer1" style="position:absolute; left:20px; top:18px; width:127px; height:23px; z-index:1"><img src="file:///C|/Archivos%20Marco%20Vasquez/Web%20Site%20Xrevolutio.net/BotonContactowhite.jpg" width="122" height="19" onMouseOver="MM_controlSound('play','document.CS10 38272830060','Boton%20Contact%20Us.mp3')"></div>
<EMBED NAME='CS1038272830060' SRC='Boton%20Contact%20Us.mp3' LOOP=false
AUTOSTART=false MASTERSOUND HIDDEN=true WIDTH=0 HEIGHT=0></EMBED>
</body>
</html>
  #2 (permalink)  
Antiguo 25/11/2002, 20:24
 
Fecha de Ingreso: diciembre-2001
Ubicación: Madrid
Mensajes: 889
Antigüedad: 22 años, 4 meses
Puntos: 4
Buenas que tal:

No sé cual será el error o porqué lo hará, pero si quieres una alternativa, te dejo éste script:

En el tag Head:
<script LANGUAGE="JavaScript">
var Sonido = new Array();
Sonido[0] = "sonido.wav"; // sonido.mid, sonido.mp3, sonido.au, etc..

document.write('<BGSOUND ID="auIEContainer">')
IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
ver4 = IE||NS? 1:0;
onload=auPreload;

function auPreload() {
if (!ver4) return;
if (NS) auEmb = new Layer(0,window);
else {
Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
document.body.insertAdjacentHTML("BeforeEnd",Str);
}
var Str = '';
for (i=0;i<Sonido.length;i++)
Str += "<EMBED SRC='"+Sonido[i]+"' 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 = auCtrl;
}
function auCtrl(whSound,play) {
if (IE) this.src = play? Sonido[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>

Ahí modifica únicamente lo que te pongo en negrita (el sonido) en la parte:
Sonido[0] = "sonido.wav";
Lo bueno que tiene, es que puedes poner más de un sonido y luego reproducir cualquiera de ellos en tus enlaces:
Sonido[1] = "sonido.wav";
Sonido[2] = "sonido.wav";
...

En el tag Body
<a href="tulink.htm" onMouseOver="playSound(0)" onMouseOut="stopSound(0)">Aquí el texto de tu link</a>

Si en el tag Head pusiste más sonidos, el que desees reproducir deberá corresponder con el mismo número.
Ejemplo:
Si queremos reproducir un sonido, nos fijaremos en el número que está en negrita:
Sonido[1] = "sonido.wav";
Y para reproducir, ponemos el enlace, con el número índice que anteriormente anotamos (el 1):
<a href="tulink.htm" onMouseOver="playSound(1)" onMouseOut="stopSound(1)">Aquí el texto de tu link</a>


Espero quede claro para quien no entienda muxo jeje.

Saludos!

Última edición por chivi; 25/11/2002 a las 20:29
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:14.