/*
* @title 音楽を鳴らすだけ
* @description 定数は調整をお願いします。音楽のポン出しに便利です。
* @license MIT License
*/
javascript:
x = "";
for (let e = 1;e<41;e++){
x = x + e + ".<input style=margin-top:50px; type=file id=" + e + "><input type=text><br><button Onclick=";
if (e >= 31 && e <= 40){
x = x + "stop();";
}
x = x + "adf[" + e + "].play();>再生</button> <button Onclick=adf[" + e + "].pause();>一時停止</button> <button Onclick=adf[" + e + "].pause();adf[" + e + "].currentTime=0;>停止</button><input type=checkbox id=xf" + e + ">ループ</input>";
if (e == 20){
x = x + "<br><br>";
} else if(e >= 31 && e <= 40){
x = x + "<button Onclick=stop();>BGM停止</button><br>";
} else {
x = x + "<br>";
}
if (e == 40){
x = x + "<div style=\"padding-bottom:200px;margin:100px;\"></div>"
}
}
let adf = new Array(41);
document.body.innerHTML = x;
document.body.style = "text-align:center;";
for(let e = 1;e<41;e++){
var x = document.getElementById(e);
x.addEventListener("change", function (x) {
document.getElementById(e).style.display = "none";
adf[e] = new Audio(URL.createObjectURL(x.target.files[0]));
adf[e].addEventListener("ended", function(){
if (document.getElementById("xf" + e).checked){
adf[e].currentTime = 0;
adf[e].play();
}
});
});
}
function stop(){
for (let e=31;e<41;e++){
if (typeof(adf[e]) == "object"){
adf[e].pause();
adf[e].currentTime = 0;
}
}
}