No seas impaciente! Los demás también tenemos cosas que hacer
Código Javascript
:
Ver originalvar videoMethods = {
videoWrapper: document.querySelectorAll('.video-wrapper'),
video: document.querySelectorAll('video'),
renderVideoPlayButton: function() {
Array.prototype.forEach.call(this.videoWrapper, function(el, i) {
if (el.contains(videoMethods.video[i])) {
videoMethods.formatVideoPlayButton(el)
videoMethods.video[i].classList.add('has-media-controls-hidden')
document.querySelectorAll('.video-overlay-play-button')[i].addEventListener('click', function() {this.hideVideoPlayButton(this, videoMethods.video[i])})
}
})
},
formatVideoPlayButton: function(vWrapper) {
return vWrapper.insertAdjacentHTML('beforeend', '\
<svg class="video-overlay-play-button" viewBox="0 0 200 200" alt="Play video">\
<circle cx="100" cy="100" r="90" fill="none" stroke-width="15" stroke="#fff"/>\
<polygon points="70, 55 70, 145 145, 100" fill="#fff"/>\
</svg>\
')
},
hideVideoPlayButton: function(vpb, v) {
v.play()
vpb.classList.add('is-hidden')
v.classList.remove('has-media-controls-hidden')
v.setAttribute('controls', 'controls')
}
}
videoMethods.renderVideoPlayButton()