Widget:AudioPlayer2: Difference between revisions

From The Midnight Wiki
No edit summary
No edit summary
Line 7: Line 7:
<includeonly>
<includeonly>
<html>
<html>
<script>
let state = false;
let btn = document.querySelector(".btn");
let record = document.querySelector(".record");
let toneArm = document.querySelector(".tone-arm");
let song = document.querySelector(".my-song");
let slider = document.querySelector(".slider");
btn.addEventListener("click", () => {
  if (state == false) {
    record.classList.add("on");
    toneArm.classList.add("play");
    setTimeout(() => {
      song.play();
    }, 1000);
  } else {
    record.classList.remove("on");
    toneArm.classList.remove("play");
    song.pause();
  }
  state = !state;
});
slider.addEventListener("input", (e) => {
  song.volume = Number(e.target.value);
});
</script>
<style>
<style>
.player {
.player {
Line 143: Line 171:
}
}
</style>
</style>
<script>
let state = false;
let btn = document.querySelector(".btn");
let record = document.querySelector(".record");
let toneArm = document.querySelector(".tone-arm");
let song = document.querySelector(".my-song");
let slider = document.querySelector(".slider");
btn.addEventListener("click", () => {
  if (state == false) {
    record.classList.add("on");
    toneArm.classList.add("play");
    setTimeout(() => {
      song.play();
    }, 1000);
  } else {
    record.classList.remove("on");
    toneArm.classList.remove("play");
    song.pause();
  }
  state = !state;
});
slider.addEventListener("input", (e) => {
  song.volume = Number(e.target.value);
});
</script>
   <div class="player-wrapper">
   <div class="player-wrapper">
     <div class="player">
     <div class="player">

Revision as of 08:34, 13 June 2023


Sample result

Press the button to play/pause

Adjust volume with slider