Grasss,
С 14:00 до 16:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="player">Воспроизведение видео на сайте по расписанию</div>
<script type="text/javascript"></script>
<script>
var start_hour = 14;
var end_hour = 16;
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '315',
width: '560',
videoId: 'dwiGTtbo6WM',
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady(event) {
event.target.playVideo();
}
var jump = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING && !jump) {
player.seekTo(getSeconds());
jump = true;
}
}
function stopVideo() {
player.stopVideo();
}
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
function getSeconds() {
if (h >= end_hour && m) return 0;
if (h >= start_hour) {
var time_now = d;
var time_start = new Date(d.getFullYear(), d.getMonth(), d.getDate(), start_hour, 0);
var time_end = new Date(d.getFullYear(), d.getMonth(), d.getDate(), end_hour, 0);
return ((time_end - time_start) - (time_end - time_now)) / 1000;
}
}
</script>
</body>
</html>