ca marche toujours
This commit is contained in:
parent
37b8156869
commit
308d0999d1
@ -61,15 +61,13 @@
|
||||
<img src="./gifs/homme trop swag.gif" alt="homme en noir" height="150" width="150">
|
||||
|
||||
<!--Insertion de l'audio a chaque saut-->
|
||||
<audio id="myAudio">
|
||||
<source src="./sons/OhPonyBoy_-_WOUTIPOUP.ogg" type="audio/ogg">
|
||||
<source src="./sons/OhPonyBoy_-_WOUTIPOUP.mp3" type="audio/mpeg">
|
||||
</audio>
|
||||
<audio id="monAudio"> </audio>
|
||||
<script src="./sons.js"></script>
|
||||
|
||||
<!--bouton evenement-->
|
||||
<br>
|
||||
<button onmousedown="sauter(-0.05)" onmouseup="sauter(0.05)">SAUTER</audio></button>
|
||||
<button onclick="playAudio()">MUSIC</audio></button>
|
||||
|
||||
|
||||
<!--lancer le jeux-->
|
||||
<script>
|
||||
|
@ -1,9 +1,46 @@
|
||||
var x = document.getElementById("myAudio");
|
||||
//ATTRIBUTS
|
||||
var son = document.getElementById("monAudio");
|
||||
|
||||
//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
|
||||
function playAudio() {
|
||||
x.play();
|
||||
var bruit = new Sound("sons\OhPonyBoy_-_WOUTIPOUP.mp3", 100, false);
|
||||
bruit.start();
|
||||
}
|
||||
|
||||
function pauseAudio() {
|
||||
x.pause();
|
||||
//GETTER
|
||||
function getSon() {
|
||||
return this.son;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user