301video.style.top = '0';302video.style.left = '0';303video.style.minHeight = '100%';304video.style.minWidth = '100%';305video.style.height = options.height + 'px';306video.style.width = options.width + 'px';307video.style.objectFit = 'cover';308video.autoplay = options.autoplay;309video.loop = options.loop;310video.muted = options.muted;311video.volume = options.volume;312video.setAttribute('playsinline', '');
video.addEventListener('canplay', function () { if (options.autoplay) { video.muted = true; video.play(); } }); var codec = options.mp4 ? 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"' : 'video/webm; codecs="vp8, vorbis"'; var emptyVideo = document.createElement('video'); var isVideoSupported = emptyVideo.canPlayType(codec); if (isVideoSupported) { video.src = options.webm || options.mp4; videoWrapper.insertAdjacentElement('beforeend', video); } else if (!videoWrapper.querySelector('.no-video-loader')) { // image for those that don't support the video var img = document.createElement('img'); img.setAttribute('src', options.poster); img.style.position = 'absolute'; img.style.zIndex = options.zIndex; img.style.top = '0'; img.style.left = '0'; img.style.minHeight = '100%'; img.style.minWidth = '100%'; img.classList.add('no-video-loader'); videoWrapper.insertAdjacentElement('beforeend', img); } return videoWrapper;}/** * set width and height to current video. * Naming without prefix, because used in blocks. * * @param {HTMLElement} el - current el * @param {string} height - height with px or vh * @param {string} type - YouTube or HTML5 video */function setWidthAndHeightVideo(el, height, type) { var iframe = el.querySelector('iframe'); var coverCarrier = el.closest('.t-cover__carrier'); if (type === 'html5') { var video = el; el = el.closest('.t-cover__carrier'); iframe = el.querySelector('video'); } var isHasCover = el.getAttribute('data-content-video-nocover') !== 'yes'; var isAdCutted = el.getAttribute('data-content-video-noadcut-youtube') !== 'yes'; var isAdCuttedInType = type === 'youtube' || type === 'rutube' || type === 'vk'; var customRatio = el.getAttribute('data-content-video-ratio'); var adCuttedPadding = isAdCutted && isAdCuttedInType ? 220 : 0; var videoRatio = 0.5625; if (customRatio && parseFloat(customRatio) > 0) videoRatio = parseFloat(customRatio); if (isHasCover) { var coverHeight = t_videoprocessor__getHeight(height, isHasCover, el, videoRatio); var videoWidth = coverCarrier?.clientWidth || window.innerWidth; var videoHeight = videoWidth * videoRatio; var deltaRatio = 1; // recalculate deltaRatio if video height less than div height if (videoHeight - adCuttedPadding < coverHeight) { deltaRatio = videoHeight < coverHeight ? coverHeight / videoHeight : videoHeight / coverHeight; deltaRatio += 0.02; } var zoomedWidth = Math.floor(videoWidth * deltaRatio); var zoomedHeight = Math.floor((videoHeight + adCuttedPadding) * deltaRatio); var heightDelta = zoomedHeight - coverHeight; var widthDelta = zoomedWidth - videoWidth; if (iframe) iframe.style.height = zoomedHeight + 'px'; if (iframe) iframe.style.width = zoomedWidth + 'px'; if (type === 'html5' && video) { video.style.height = coverHeight + 'px'; video.style.width = videoWidth + 'px'; } if (iframe) iframe.style.marginTop = heightDelta > 0 ? -Math.floor(heightDelta / 2) + 'px' : '0'; if (iframe) iframe.style.marginLeft = widthDelta > 0 ? -Math.floor(widthDelta / 2) + 'px' : '0'; } else { var noCoverHeight = t_videoprocessor__getHeight(height, isHasCover, el, videoRatio); if (type === 'html5' && video) {