Как показывать видео через определенный период?

Добрый день!
Нужно показывать расписание и через определенные интервалы 2 видео.
<table class="minimalistBlack"> ...</table>
<video class="videoMain video-js" id="video1" muted autoplay preload="auto">
                <source src="src1" type="video/mp4">
</video>
<video class="videoMain video-js" id="video2" muted autoplay preload="auto">
                <source src="src2" type="video/mp4">
</video>

Скрипт написал, все работает, но постоянно сбиваются таймеры
JavaScript

var timeBeforeReload = 3600000;
		var firstChangeMs = 1200000;
		var secondChangeMs = 3438000;
		var video1 = document.querySelector('#video1');
		var video2 = document.querySelector('#video2');
		var table = document.querySelector('table');
		var counter;

		showSchedule();

		function showFirstVideo() {
			table.style.display = 'none';
			video1.style.display = 'block';
			video2.style.display = 'none';

			clearTimeout(firstTimer);
		}

		function showSecondVideo() {
			table.style.display = 'none';
			video1.style.display = 'none';
			video2.style.display = 'block';

			clearTimeout(secondTimer);
		}

		function reload() {
			clearTimeout(firstTimer);
			clearTimeout(secondTimer);
			document.location.reload(true);
		}

		function showSchedule() {
			table.style.display = 'block';
			video1.style.display = 'none';
			video2.style.display = 'none';
		}

		var firstTimer = setTimeout(showFirstVideo, firstChangeMs);
		var secondTimer = setTimeout(showSecondVideo, secondChangeMs);
		setTimeout(reload, timeBeforeReload);
  • Вопрос задан
  • 45 просмотров
Пригласить эксперта
Ответы на вопрос 1
Seasle
@Seasle Куратор тега JavaScript

Видео просто нагуглил рандомные.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы