Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
I have been trying to make a application which automatically Start and stops Music

var curtime = document.querySelector('#curtime')
var starttime = "11:57"
var stoptime = "11:58"
var timetime = moment().format("HH:mm");
var video = document.querySelector("#ytplayer")


setInterval(function(){
    var currenttime = moment().format("HH:mm:ss");
    curtime.textContent = currenttime;
});



function checktime (timetime){
    if (timetime = starttime){
        video.src = 'https://www.youtube.com/embed/Dx5qFachd3A?autoplay=1'
    }
    if (timetime = stoptime){
        video.src = ''
    }

}
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./assets/CSS/style.css">
    <title>Music</title>
</head>
<body>
    <header>

        <div class="time">
            <span id="curtime"></span>
        </div>

    </header>
    <main>
        <section>
            <iframe id="ytplayer" type="text/html" width="720" height="405"
            src=""
            frameborder="0" allowfullscreen></iframe>
        </section>

    </main>
    
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
<script src="./assets/JS/main.js"></script>
</html>

I have been trying to create an application for restaurants where the restaurant owners can open the webpage set a start time and end time and add a youtube URL and the webpage will automatically start and stop music at the provided time I am using moment

I tried using .play() and .pause() but that wasnt working In return I got the .play() and .pause() is not a function so i went with the .src approach .src approach is working with button but not with a 'if' function

Anybody with ideas will be greatly appreciated

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!