Некодим логотипНекодим
МодификацииПубликацииНекодИИмЦены
Некодим логотипНекодим

© 2020-2026 Некодим

Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.

Компания

  • Контакты
  • Публичная оферта
  • Политика конфиденциальности
  • Согласие на обработку данных
  • Лицензионное соглашение
  • Реферальная программа

Полезное

  • Модификации
  • Публикации
  • Каталог блоков Tilda
  • MCP для агентов
  • Журнал изменений
  • Доска почёта

Личный кабинет

  • Вход
  • Регистрация
  • Цены
Журнал измененийИстория GitФайлыTilda MCP
Каталог файлов

tilda-video-processor-1.0.js

Код файла
Версия от 09.10.2026, 07:01:06 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
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);
История файла и сравнение версий
  • 09.10.2026, 07:01:06 · 56c3b845
112
iframe.frameBorder = '0';
113 iframe.allow = 'fullscreen';
114 iframe.style.opacity = '0'; // prevent white background while processing video
115 el.appendChild(iframe);
116
117 var playtimer;
118
119 const player = new YT.Player(iframe, {
120 events: {
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');
126 }
127 iframe.style.opacity = '';
128 t_videoprocessor__pauseAndPlayYouTubeVideo(el, e.target, videoObject['mute']);
129 t_videoprocessor__muteYouTubeVideo(e, videoObject);
130 e.target.setLoop(true);
131 },
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);
136 } else {
137 window.clearInterval(playtimer);
138 }
139 },
140 },
141 });
142}
143
144/**
145 * mute created video
146 *
147 * @param {Event} e
148 * @param {Object} videoObject
149 */
150function t_videoprocessor__muteYouTubeVideo(e, videoObject) {
151 if (e.target.setVolume && videoObject['mute']) {
152 e.target.setVolume(0);
153 }
154}
155
156/**
157 * remove black window between stop and play again video
158 *
159 * @param {Object} el - player
160 * @param {Object} videoObject
161 * @return {number} - an interval, that checks ending of the video
162 */
163function t_videoprocessor__updateLoopedVideo(el, videoObject) {
164 return setInterval(function () {
165 // time in sec
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']) {
171 el.stopVideo();
172 el.clearVideo();
173 }
174 }
175 }, 1000);
176}
177
178/**
179 * function to generate mp4 or .webm video
180 *
181 * @param {HTMLElement} el
182 * @param {Object} options
183 */
184function t_videoprocessor__processHTML5Video(el, options) {
185 if (!el) return;
186
187 var computedStyle = window.getComputedStyle(el);
188
189 // container to be at least relative
190 if (computedStyle.position === 'static' || !el.style.position) {
191 el.style.position = 'relative';
192 }
193 //set height
194 options.height = el.offsetHeight;
195
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);
200 }
Предыдущие 100 строкСледующие 100 строк