Skip Ad In Seconds var videocount =1; var player=document.getElementById('myvid'); player.addEventListener('ended',dispositor); function dispositor(x){ if(!x) { x = window.event; } videocount++; if (videocount > 2){ // last number of video playing in loop. videocount = 1;} player.src="https://cdn.primetime.ge/qaquca.mp4"; //ვიდეოს ლინკი } var video = document.getElementById("myvid"); var button = document.getElementById("btnCounter"); button.addEventListener("click", function(e) { console.log(video.duration); video.play(); video.pause(); video.currentTime = video.duration; // video.play(); }) // Get refreence to span and button var spn = document.getElementById("count"); var btn = document.getElementById("btnCounter"); var count = 5; // Set count var timer = null; // For referencing the timer (function countDown(){ // Display counter and start counting down spn.textContent = count; // Run the function again every second if the count is not zero if(count !== 0){ timer = setTimeout(countDown, 1000); count--; // decrease the timer } else { // Enable the button btn.removeAttribute("disabled"); } }());