Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/11/2008, 01:06
Avatar de caricatos
caricatos
Moderador
 
Fecha de Ingreso: abril-2002
Ubicación: Torremolinos (Málaga)
Mensajes: 19.607
Antigüedad: 22 años, 1 mes
Puntos: 1284
Respuesta: "precargar" archivo

Hola:

Luego de crear ese mensaje, hice algunas modificaciones y como último (no sé si definitivo) script es el siguiente:

Código:
<html>
<head>
<title>
	precarga de sonidos
</title>
<script type="text/javascript">
var sones;
function _desactivar() {
	window.frames[this.nFrame].document.clear();
	window.frames[this.nFrame].document.open();
	window.frames[this.nFrame].document.writeln("");
	window.frames[this.nFrame].document.close();
}
function _activar() {
	var son = "<html><body><embed";
	son += " src='" + this.son[_activar.arguments[0]].src + "' autostart='true'";
	son += " hidden='true' style='display: inline'></embed></body></html>";
	window.frames[this.nFrame].document.clear();
	window.frames[this.nFrame].document.open();
	window.frames[this.nFrame].document.writeln(son);
	window.frames[this.nFrame].document.close();
}
function preSonidos() {
	this._contenedor = document.createElement("div");
	this._contenedor.style.width = "0px";
	this._contenedor.style.height = "0px";
	this._contenedor.style.overflow = "hidden";
	this._sonador = document.createElement("iframe");
	this._contenedor.appendChild(this._sonador);
	this._sonador.setAttribute("name", "fondoMusical");
	this._entradas = preSonidos.arguments;
	this.total = this._entradas.length; this.son = new Array(this.total);
	for (var i = 0; i < this.total; i ++) {
		this.son[i] = document.createElement("embed");
		this.son[i].src = this._entradas[i];
		this.son[i].autostart = false;
		this.son[i].style.display = "none";
		this._contenedor.appendChild(this.son[i]);
	}
	this.sonando = false;
	this.incrustado = false;
	this.activar = _activar;
	this.desactivar = _desactivar;
	document.body.appendChild(this._contenedor);
	this.nFrame = window.frames.length - 1;
}

function ini() {
	sones = new preSonidos('../sonidos/celtic0.mid',
'../sonidos/celtic1.mid', '../sonidos/celtic2.mid',
'../sonidos/celtic3.mid', '../sonidos/Starway_to_Heaven.mp3');
}
</script>
</head>
<body onload="ini();">
<button onclick="sones.activar(0)">celtic0.mid</button>
<button onclick="sones.activar(1)">celtic1.mid</button>
<button onclick="sones.activar(2)">celtic2.mid</button>
<button onclick="sones.activar(3)">celtic3.mid</button>
<button
onclick="sones.activar(4)">Starway_to_Heaven.mp3</button>
<button onclick="sones.desactivar()">desactivar</button>
<br />
</body>
</html>
Puedes probarlo aquí: Probador de scripts (copiar y pegar)... De paso te muestro otro enlace de interés: Música en la web

Saludos
__________________
Por favor:
No hagan preguntas de temas de foros en mensajes privados... no las respondo