JSFiddle - React, Tailwind, and code Playground
by boba01k
HTML
<div class="video-overlay" id="skipp">
<div id="video_holder">
<div id="overlay"></div>
<!--тут партнерская ссылка-->
<a href="https://google.com" target="blank">
<!--допполе откуда будет братся превью для видео-->
<video poster="[xfvalue_thumb]" id="myVideo">
<!--тут ссылка на рекламный ролик-->
<source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
</video>
</a>
</div>
<div class="content-video">
<!--Вместо 10 указываем любое число через которое можно будет пропустить рекламу -->
<button id="myBtn">Skip add (10)</button>
</div>
</div>
<!--Это у вас есть-->
<iframe allowfullscreen frameborder="0" height="473px" id="player" name="player" scrolling="no" src="https://www.youtube.com/embed/czPDFvHezPQ" width="100%"></iframe>
CSS
.video-overlay{
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: 9999;
}
/* Style the video: 100% width and height to cover the entire window */
#myVideo {
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
z-index: 99
}
/* Add some content at the bottom of the video/page */
.content-video {
position: inherit;
bottom: 0;
color: #f1f1f1;
width: 100%;
z-index: 999;
height: 37px;
padding: 15px 15px;
flex-wrap: wrap-reverse;
display: flex;
flex-direction: row;
justify-content: flex-end;
}
/* Style the button used to pause/play the video */
#myBtn {
font-size: 0.8rem;
padding: 10px;
border: none;
color: #fff;
cursor: pointer;
background: #ffffff00;
position: absolute;
z-index: 9999;
visibility: hidden;
}
#video_holder{
position: relative;
width: 100%;
height: 100%;
}
#overlay{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 999;
background: url('https://gosolarpower.com/wp-content/uploads/2018/10/green-play-symbol.svg_.hi_-1.png') center/25% no-repeat;
cursor: pointer;
}
#overlay.o{
display: none;
}
JavaScript
document.getElementById('overlay').onclick = function() {
function timer(){
var obj=document.getElementById('myBtn');
var regexp = /(\d+)/i;
var RealTimer = regexp.exec(obj.innerHTML)[0];
$('#myBtn').css('visibility', 'visible');
if (--RealTimer < 0) RealTimer = 0;
obj.innerHTML = 'Skip add in ( '+RealTimer+' )';
if (RealTimer==0) {
$('#myBtn').css({'pointer-events': 'all', 'background' : '#0000004d'
})
$("#myBtn").empty();
$("#myBtn:empty").text("Skip add ➡");
return; }
else {
setTimeout(timer,1000); }
}
setTimeout(timer,0);
}
document.getElementById('myBtn').onclick = function() {
var media = $("#myVideo").get(0);
media.pause();
media.currentTime = 0;
document.getElementById('skipp').hidden = true;
}
var overlay = document.getElementById('overlay');
var vid = document.getElementById('myVideo');
if(overlay.addEventListener){
overlay.addEventListener("click", play, false)
}else if(overlay.attachEvent){
overlay.attachEvent("onclick", play)
}
function play() {
if (vid.paused){
vid.play();
overlay.className = "o";
}else {
vid.pause();
overlay.className = "";
}
}
vid.addEventListener('ended', function(e) {
//alert('The...