Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda