Каталог файловtilda-video-processor-1.0.js
101 var customHeight = t_videoprocessor__getHeightFromAttr(height);102 var calculatedHeight = parseInt(el.getAttribute('data-content-cover-updated-height'), 10) || 0;103 currentHeight = calculatedHeight > customHeight ? el.getAttribute('data-content-cover-updated-height') : height;104 }105 setWidthAndHeightVideo(el, currentHeight, type);106}107 108function t_videoprocessor__setYoutubePlayer(el, videoObject) {109 // create YouTube iframe110 var iframe = document.createElement('iframe');111 iframe.src = t_videoprocessor__generateYoutubeURL(videoObject);
История файла и сравнение версий
iframe.frameBorder = '0';
113 iframe.allow = 'fullscreen'; 114 iframe.style.opacity = '0'; // prevent white background while processing video 115 el.appendChild(iframe); 119 const player = new YT.Player(iframe, { 121 onReady: function (e) { 122 // update src and reinit iframe, if player cannot play video at first time 123 if (e.target.getPlayerState() === -1 && iframe.getAttribute('programmly-updated') !== 'y') { 124 iframe.src = t_videoprocessor__generateYoutubeURL(videoObject); 125 iframe.setAttribute('programmly-updated', 'y'); 127 iframe.style.opacity = ''; 128 t_videoprocessor__pauseAndPlayYouTubeVideo(el, e.target, videoObject['mute']); 129 t_videoprocessor__muteYouTubeVideo(e, videoObject); 130 e.target.setLoop(true); 132 onStateChange: function (e) { 133 t_videoprocessor__muteYouTubeVideo(e, videoObject); 134 if (e.data === YT.PlayerState.PLAYING) { 135 playtimer = t_videoprocessor__updateLoopedVideo(e.target, videoObject); 137 window.clearInterval(playtimer); 148 * @param {Object} videoObject 150function t_videoprocessor__muteYouTubeVideo(e, videoObject) { 151 if (e.target.setVolume && videoObject['mute']) { 152 e.target.setVolume(0); 157 * remove black window between stop and play again video 159 * @param {Object} el - player 160 * @param {Object} videoObject 161 * @return {number} - an interval, that checks ending of the video 163function t_videoprocessor__updateLoopedVideo(el, videoObject) { 164 return setInterval(function () { 166 var currentTime = el.getCurrentTime(); 167 var endVideoTime = el.getDuration(); 168 if (endVideoTime && currentTime + 1 > endVideoTime) { 169 el.seekTo(0); // return to the beginning (0sec) 170 if (videoObject['noloop']) { 179 * function to generate mp4 or .webm video 181 * @param {HTMLElement} el 182 * @param {Object} options 184function t_videoprocessor__processHTML5Video(el, options) { 187 var computedStyle = window.getComputedStyle(el); 189 // container to be at least relative 190 if (computedStyle.position === 'static' || !el.style.position) { 191 el.style.position = 'relative'; 194 options.height = el.offsetHeight; 196 var initialHeight = parseInt(computedStyle.height.replace('px', ''), 10); 197 var initialWidth = parseInt(computedStyle.width.replace('px', ''), 10); 198 if ((window.t_cover__isMobile || 'ontouchend' in document) && initialWidth < initialHeight) { 199 el.setAttribute('data-content-video-ratio', initialHeight / initialWidth);