ca marche toujours

This commit is contained in:
Chiara 2019-12-06 05:19:40 +01:00
parent 37b8156869
commit 308d0999d1
2 changed files with 45 additions and 10 deletions

View File

@ -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>

View File

@ -1,9 +1,46 @@
var x = document.getElementById("myAudio"); //ATTRIBUTS
var son = document.getElementById("monAudio");
function playAudio() { //CONSTRUCTEUR
x.play(); // 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;
}
} }
function pauseAudio() { //METHODE
x.pause(); function playAudio() {
var bruit = new Sound("sons\OhPonyBoy_-_WOUTIPOUP.mp3", 100, false);
bruit.start();
}
//GETTER
function getSon() {
return this.son;
} }