2019-12-06 05:19:40 +01:00
|
|
|
//ATTRIBUTS
|
|
|
|
var son = document.getElementById("monAudio");
|
2019-12-06 04:12:43 +01:00
|
|
|
|
2019-12-06 05:19:40 +01:00
|
|
|
//CONSTRUCTEUR
|
|
|
|
// source: https://stackoverflow.com/a/11331200/4298200
|
|
|
|
function Sound(source, volume, loop) {
|
|
|
|
this.source = source;
|
|
|
|
this.volume = volume;
|
|
|
|
this.loop = loop;
|
|
|
|
var son;
|
|
|
|
this.son = son;
|
|
|
|
this.finish = false;
|
|
|
|
this.stop = function() {
|
|
|
|
document.body.removeChild(this.son);
|
|
|
|
}
|
|
|
|
this.start = function() {
|
|
|
|
if (this.finish) return false;
|
|
|
|
this.son = document.createElement("embed");
|
|
|
|
this.son.setAttribute("src", this.source);
|
|
|
|
this.son.setAttribute("hidden", "true");
|
|
|
|
this.son.setAttribute("volume", this.volume);
|
|
|
|
this.son.setAttribute("autostart", "true");
|
|
|
|
this.son.setAttribute("loop", this.loop);
|
|
|
|
document.body.appendChild(this.son);
|
|
|
|
}
|
|
|
|
this.remove = function() {
|
|
|
|
document.body.removeChild(this.son);
|
|
|
|
this.finish = true;
|
|
|
|
}
|
|
|
|
this.init = function(volume, loop) {
|
|
|
|
this.finish = false;
|
|
|
|
this.volume = volume;
|
|
|
|
this.loop = loop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//METHODE
|
2019-12-06 04:12:43 +01:00
|
|
|
function playAudio() {
|
2019-12-06 05:19:40 +01:00
|
|
|
var bruit = new Sound("sons\OhPonyBoy_-_WOUTIPOUP.mp3", 100, false);
|
|
|
|
bruit.start();
|
2019-12-06 04:12:43 +01:00
|
|
|
}
|
|
|
|
|
2019-12-06 05:19:40 +01:00
|
|
|
//GETTER
|
|
|
|
function getSon() {
|
|
|
|
return this.son;
|
2019-12-06 04:12:43 +01:00
|
|
|
}
|