View Full Version : music play
skynet
09-02-2005, 03:50 PM
Anyone figured out how to play several mids one after another as background music? (When mid1 ends, mid2 should start playing, and so on ...). :confused:
Or is this really impossible?
skynet
09-15-2005, 04:58 PM
It seems to be impossible.
martin_narg
09-15-2005, 07:33 PM
It's pretty easy to do: Something like this should work, although it's untested:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
var soundsCounter = 0;
var sounds = [];
// add sounds below, the number is the length in ms of the track
sounds.push(["myMidi.mid", 45345]);
sounds.push(["anotherMidi.mid", 44354]);
sounds.push(["oneMore.mid", 34534]);
sounds.push(["/myMidiFolder/lastOne.mid", 55465]);
function playSound() {
var obj = document.getElementById("backgroundMusic") || null;
var e = document.createElement("embed");
with(e) {
setAttribute("id", "backgroundMusic");
setAttribute("height", 0);
setAttribute("width", 2);
setAttribute("autostart", true);
setAttribute("src", sounds[soundsCounter][0]);
}
if(obj) {
obj.parentNode.replaceChild(e, obj);
} else {
document.getElementsByTagName("body")[0].appendChild(e);
}
setTimeout("playSound()", sounds[soundsCounter][1]);
soundsCounter++;
if(soundsCounter = sounds.length) {
soundsCounter = 0;
}
}
window.onload = function() {
playSound();
}
</script>
</head>
<body>
</body>
</html>
Hope this helps
m_n
Cipher
09-15-2005, 11:16 PM
i think it will work like this :D
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.