Tenho o seguinte código abaixo que mostra um cronometro regressivo em minha página, a ideia é que ao zerar ele mostre um iframe(video), até mostra porem o vídeo fica piscando como se somente ele ficasse em loop de atualização eterna. Se alguém tiver a solução agradeceria sou iniciante nesta área.
(function($) {
var launch = new Date(2018, 4, 25, 23, 42);
var message = $('#message');
var days = $('#days');
var hours = $('#hours');
var minutes = $('#minutes');
var seconds = $('#seconds');
setDate();
function setDate(){
var now = new Date();
if( launch < now){
days.html('<h1>0</H1><p>Dia</p>');
hours.html('<h1>0</h1><p>Hora</p>');
minutes.html('<h1>0</h1><p>Minuto</p>');
seconds.html('<h1>0</h1><p>Segundos</p>');
message.html('<iframe width="560" height="315" src="https://www.youtube.com/embed/IsHOEl5N0cA?rel=0&start=289" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>');
}
else{
var s = -now.getTimezoneOffset()*60 + (launch.getTime() - now.getTime())/1000;
var d = Math.floor(s/86400);
days.html('<h1>'+d+'</h1><p>Dia'+(d>1?'s':''),'</p>');
s -= d*86400;
var h = Math.floor(s/3600);
hours.html('<h1>'+h+'</h1><p>Hora'+(h>1?'s':''),'</p>');
s -= h*3600;
var m = Math.floor(s/60);
minutes.html('<h1>'+m+'</h1><p>Minuto'+(m>1?'s':''),'</p>');
s = Math.floor(s-m*60);
seconds.html('<h1>'+s+'</h1><p>Segundo'+(s>1?'s':''),'</p>');
setTimeout(setDate, 1000);
message.html('PRÓXIMO TREINO INICIA EM... ');
/**if(d == -1){
days.html('<h1>0</H1><p>Dia</p>');
hours.html('<h1>0</h1><p>Hora</p>');
minutes.html('<h1>0</h1><p>Minuto</p>');
seconds.html('<h1>0</h1><p>Segundos</p>');
message.html('<iframe width="560" height="315" src="https://www.youtube.com/embed/IsHOEl5N0cA?rel=0&start=289" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>');
}**/
}
}
})(jQuery);