mercredi 20 septembre 2017

Start a countdown in a specific time depending on my video timer and pause the countdown when the video is paused

I have a countdown and a video in my page. I want to start the countdown in a specific time depending to the video timer and pause my countdown when the video is paused. Here is my actual code:

$(document).ready(function() {
        
                        document.getElementById('timer1').innerHTML = 7 + ":" + 55;
                        startTimer();
                        

            

            function startTimer() {
                var presentTime = document.getElementById('timer1').innerHTML;
                var timeArray = presentTime.split(/[:]+/);
                var m = timeArray[0];
                var s = checkSecond((timeArray[1] - 1));
                if (s == 59) {
                    m = m - 1
                }


                document.getElementById('timer1').innerHTML =
                    "0" + (m < 10 ? m-- : "") + ":" + s;
                setTimeout(startTimer, 1000);
            }

            function checkSecond(sec) {
                if (sec < 10 && sec >= 0) {
                    sec = "0" + sec
                }; // add zero in front of numbers < 10
                if (sec < 0) {
                    sec = "59"
                };
                return sec;
            }
        });
<script src="http://ift.tt/1oMJErh"></script>
<video id="video1">
<source src="myvideo.mp4" type="video/mp4">
</video>


<div class="inline_timer hidden" id="element_1" align="center">
   <h3><span id="timer1"></span><span> The MASSIVE Thyroid Secret Is Revealed...</span></h3>
        
</div>

Can anyone help me figured it out please?




Aucun commentaire:

Enregistrer un commentaire