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">
|
<img src="./gifs/homme trop swag.gif" alt="homme en noir" height="150" width="150">
|
||||||
|
|
||||||
<!--Insertion de l'audio a chaque saut-->
|
<!--Insertion de l'audio a chaque saut-->
|
||||||
<audio id="myAudio">
|
<audio id="monAudio"> </audio>
|
||||||
<source src="./sons/OhPonyBoy_-_WOUTIPOUP.ogg" type="audio/ogg">
|
<script src="./sons.js"></script>
|
||||||
<source src="./sons/OhPonyBoy_-_WOUTIPOUP.mp3" type="audio/mpeg">
|
|
||||||
</audio>
|
|
||||||
|
|
||||||
<!--bouton evenement-->
|
<!--bouton evenement-->
|
||||||
<br>
|
<br>
|
||||||
<button onmousedown="sauter(-0.05)" onmouseup="sauter(0.05)">SAUTER</audio></button>
|
<button onmousedown="sauter(-0.05)" onmouseup="sauter(0.05)">SAUTER</audio></button>
|
||||||
<button onclick="playAudio()">MUSIC</audio></button>
|
|
||||||
|
|
||||||
<!--lancer le jeux-->
|
<!--lancer le jeux-->
|
||||||
<script>
|
<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() {
|
function playAudio() {
|
||||||
x.play();
|
var bruit = new Sound("sons\OhPonyBoy_-_WOUTIPOUP.mp3", 100, false);
|
||||||
|
bruit.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
function pauseAudio() {
|
//GETTER
|
||||||
x.pause();
|
function getSon() {
|
||||||
|
return this.son;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user