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

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

    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">
    <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">

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

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

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

I have been trying to create a 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 on 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

Source: JavaSript – Stack Overflow

November 20, 2021
Category : News
Tags: html | javascript | momentjs

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.