ADVERTISEMENT

Record Player using HTML, CSS & JavaScript

Telegram Group Join Now

ADVERTISEMENT

Record Player using HTML, CSS & JavaScript

Introduction

ADVERTISEMENT

ADVERTISEMENT

Hello, today we’re going to learn how to use HTML, CSS & JavaScript to create a Record Player. By following these instructions, you can simply make this Record Player in HTML, CSS & JavaScript. Simply by adhering to the procedures mentioned below, you will be able to develop this amazing Record Player.

Working Record Player Javascript Project

ADVERTISEMENT

Project Description

Step 1
The HTML (Hypertext Markup Language) will help us to create the structure for the list with some necessary attributes and elements to make Working Record Player Project.

ADVERTISEMENT

Step 2
Then we will use CSS (Cascading Stylesheet) which will help us to style or design the project with suitable padding and alignment in the Working Record Player Project.

Step 3
At last we will use JS (JavaScript) which will add a logic to make the Working Record Player Project functioning from the user end.

I hope you have got an idea about the project.

ADVERTISEMENT

50+ HTML, CSS & JavaScript Projects With Source Code

HTML Code for Record Player

<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Record Player</title>
    <!-- Stylesheet -->
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <div class="player">
      <div class="record">
        <div class="label"></div>
      </div>
      <div class="tone-arm">
        <div class="control"></div>
      </div>
      <button class="btn"></button>
      <div class="slider-container">
        <input
          type="range"
          class="slider"
          min="0"
          max="1"
          step="0.1"
          value="0.7"
        />
      </div>
    </div>
    <audio loop class="my-song" src="Home.mp3" preload="auto"></audio>
    <!-- Script -->
    <script src="script.js"></script>
  </body>
</html>

First we’ll start with creating the structure of the Working Record Player project for that as you can see the above code we have used all the necessary elements & attributes to setup the structure. Let us know code the CSS part to add styling and aligned the tags.

CSS Code for Record Player

* {
  padding: 0;
  margin: 0;
}
body {
  background-color: #f8d76e;
}
.player {
  background-color: #d52f31;
  width: 330px;
  height: 190px;
  position: absolute;
  transform: translate(-50%, -50%);
  left: 50%;
  top: 50%;
  border-radius: 8px;
  box-shadow: 0 8px 0 0 #be272a;
}
.record {
  height: 175px;
  width: 175px;
  background-color: #181312;
  border-radius: 50%;
  position: absolute;
  top: 10px;
  left: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.record:before,
.record:after {
  position: absolute;
  content: "";
  border: 5px solid transparent;
  border-top-color: #2c2424;
  border-bottom-color: #2c2424;
  border-radius: 50%;
}
.record:before {
  height: 135px;
  width: 135px;
}
.record:after {
  height: 95px;
  width: 95px;
}
.label {
  background-color: #181312;
  height: 15px;
  width: 15px;
  border: 20px solid #ff8e00;
  border-radius: 50%;
}
.tone-arm {
  height: 90px;
  width: 6px;
  background-color: #ffffff;
  position: absolute;
  top: 25px;
  right: 95px;
  transition: 1s;
  transform-origin: top;
}
.control {
  background-color: #181312;
  height: 17px;
  width: 17px;
  border: 10px solid #2c2c2c;
  border-radius: 50%;
  position: absolute;
  top: -16px;
  left: -16px;
}
.tone-arm:before {
  content: "";
  height: 40px;
  width: 6px;
  background-color: #ffffff;
  position: absolute;
  transform: rotate(30deg);
  bottom: -36px;
  right: 10px;
}
.tone-arm:after {
  content: "";
  position: absolute;
  height: 0;
  width: 10px;
  border-top: 18px solid #b2aea6;
  border-left: 2px solid transparent;
  border-right: 2px solid transparent;
  top: 108px;
  right: 12.5px;
  transform: rotate(30deg);
}
.btn {
  height: 28px;
  width: 28px;
  background-color: #ed5650;
  border-radius: 50%;
  position: absolute;
  bottom: 20px;
  right: 30px;
  border: none;
  border: 3.5px solid #be272a;
  outline: none;
  cursor: pointer;
}
.slider {
  -webkit-appearance: none;
  appearance: none;
  transform: rotate(-90deg);
  width: 90px;
  height: 7px;
  position: absolute;
  left: 233px;
  top: 60px;
  background-color: #be272a;
  outline: none;
  border-radius: 3px;
  border: 6px solid #ed5650;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 12px;
  background-color: #ffffff;
  cursor: pointer;
}
.play {
  transform: rotate(30deg);
  transform-origin: top;
  transition: 1s;
}
.on {
  animation: spin 3s 1s linear infinite;
}
@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

Second comes the CSS code, which is mentioned above in that we have styled for the structure we have padded as well as aligned the Record Player project so that it is properly situated and doesn’t get messy with suitable CSS elements. Now we have created the structure using HTML and styled the webpage using CSS its time to add the functionality using JavaScript in this project.

ADVERTISEMENT

JavaScript Code for Record Player

10+ Javascript Projects For Beginners With Source Code

ADVERTISEMENT

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);
});

Last stage of the project the JavaScript in which we have added the logical and coded as per the requirement with some conditions. To make the project functioning we have added the a function called addEventListener which make the player pause and play as per the user action. Let us see the Final Output of the project Record Player using HTML, CSS & JavaScript (Source Code).

Output

Live Preview of Record Player using HTML, CSS & JavaScript

See the Pen
Record Player
by Harsh Sawant (@harshh9)
on CodePen.

We have Successfully created our Working Record Player using HTML, CSS & JavaScript. You can use this project for your personal needs and the respective lines of code are given with the code pen link mentioned above.

If you find out this Blog helpful, then make sure to search code with random on google for Front End Projects with Source codes and make sure to Follow the Code with Random Instagram page.

ADVERTISEMENT

Code Idea – codingartist

ADVERTISEMENT

Written By – Harsh Sawant

ADVERTISEMENT

Code By – @harshh9

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

Telegram Group Join Now

Share on:

Leave a Comment

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT