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