It's first time I'm using stackoverflow :) I have created an interaction using javascript for playing video with timer. The interaction is... the video will be paused by default and after 3 seconds that will start playing. This same thing I have to repeat three times. Can we do that? I have shared my code here.
var timeLeft = 3;
var elem = document.querySelector('.countdown-content__count');
var timerId;
function countdown() {
if (timeLeft == 0) {
clearTimeout(timerId);
$(".countdown-content__timer").fadeOut();
$(".video-wrapper span").fadeOut();
var playPromise = $("#video")[0].play();
console.log(playPromise);
} else {
elem.innerHTML = timeLeft;
timeLeft--;
}
}
function practiceShot(){
setTimeout(function(){
$(".countdown-content__head").slideUp(1000, function(){
$(".countdown-content__timer").css({
opacity: 0,
display: 'inline-block'
}).animate({opacity:1},600);
timerId = setInterval(countdown, 1000);
countdown();
});
}, 2000);
}
practiceShot();
jfiddle link for more clarification : jsfiddle code