PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.0.5
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.0.5
4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / assets / js / initplyr.js
embedpress / assets / js Last commit date
vendor 7 years ago admin.js 2 years ago ads.js 2 years ago carousel.min.js 2 years ago documents-viewer-script.js 3 years ago front.js 2 years ago glider.min.js 2 years ago gutneberg-script.js 2 years ago index.html 7 years ago initCarousel.js 2 years ago initplyr.js 2 years ago instafeed.js 2 years ago license.js 2 years ago pdfobject.min.js 3 years ago plyr.polyfilled.js 3 years ago preview.js 3 years ago settings.js 6 years ago vimeo-player.js 2 years ago ytiframeapi.js 2 years ago
initplyr.js
257 lines
1 /**
2 * Note: This is complex initialization, but it is necessary for Gutenberg and Elementor compatibility. There are some known issues in Gutenberg that require this complex setup.
3 */
4 var playerInit = [];
5
6 // Event listener for when the DOM content is loaded
7 document.addEventListener('DOMContentLoaded', function () {
8
9
10 const overlayMask = document.createElement('div');
11 overlayMask.className = 'overlay-mask';
12
13
14 // Select all embed wrappers with the class 'ep-embed-content-wraper'
15 let embedWrappers = document.querySelectorAll('.ep-embed-content-wraper');
16
17 // Initialize the player for each embed wrapper
18 embedWrappers.forEach(wrapper => {
19 initPlayer(wrapper);
20 });
21
22 // Mutation observer to detect any changes in the DOM
23 const observer = new MutationObserver(mutations => {
24 mutations.forEach(mutation => {
25 const addedNodes = Array.from(mutation.addedNodes);
26 addedNodes.forEach(node => {
27 traverseAndInitPlayer(node);
28 });
29 });
30 });
31
32 // Start observing changes in the entire document body and its subtree
33 observer.observe(document.body, { childList: true, subtree: true });
34
35 // Recursive function to traverse the DOM and initialize the player for each embed wrapper
36 function traverseAndInitPlayer(node) {
37 if (node.nodeType === Node.ELEMENT_NODE && node.classList.contains('ep-embed-content-wraper')) {
38 initPlayer(node);
39 }
40
41 if (node.hasChildNodes()) {
42 node.childNodes.forEach(childNode => {
43 traverseAndInitPlayer(childNode);
44 });
45 }
46 }
47
48
49 });
50
51
52 // Function to initialize the player for a given wrapper
53 function initPlayer(wrapper) {
54 const playerId = wrapper.getAttribute('data-playerid');
55
56 // Get the options for the player from the wrapper's data attribute
57 let options = document.querySelector(`[data-playerid='${playerId}']`)?.getAttribute('data-options');
58
59 if (!options) {
60 return false;
61 }
62
63 // Parse the options string into a JSON object
64 if (typeof options === 'string') {
65 try {
66 options = JSON.parse(options);
67 } catch (e) {
68 console.error('Invalid JSON format:', e);
69 return;
70 }
71 } else {
72 console.error('Options is not a string');
73 return;
74 }
75
76
77 // Create DOM elements from the icon strings
78 const pipPlayIconElement = document.createElement('div');
79 pipPlayIconElement.className = 'pip-play';
80 pipPlayIconElement.innerHTML = '<svg width="20" height="20" viewBox="-0.15 -0.112 0.9 0.9" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin" class="jam jam-play"><path fill="#fff" d="M.518.357A.037.037 0 0 0 .506.306L.134.08a.039.039 0 0 0-.02-.006.038.038 0 0 0-.038.037v.453c0 .007.002.014.006.02a.039.039 0 0 0 .052.012L.506.37A.034.034 0 0 0 .518.358zm.028.075L.174.658A.115.115 0 0 1 .017.622.109.109 0 0 1 0 .564V.111C0 .05.051 0 .114 0c.021 0 .042.006.06.017l.372.226a.11.11 0 0 1 0 .189z"/></svg>';
81 pipPlayIconElement.style.display = 'none';
82
83
84 const pipPauseIconElement = document.createElement('div');
85 pipPauseIconElement.className = 'pip-pause';
86 pipPauseIconElement.innerHTML = '<svg fill="#fff" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 2.5 2.5" xml:space="preserve"><path d="M1.013.499 1.006.5V.499H.748a.054.054 0 0 0-.054.054v1.394c0 .03.024.054.054.054h.266a.054.054 0 0 0 .054-.054V.553a.054.054 0 0 0-.054-.054zm.793 1.448V.553a.054.054 0 0 0-.054-.054L1.745.5V.499h-.258a.054.054 0 0 0-.054.054v1.394c0 .03.024.054.054.054h.265a.054.054 0 0 0 .054-.054z"/></svg>';
87
88 const pipCloseElement = document.createElement('div');
89 pipCloseElement.className = 'pip-close';
90 pipCloseElement.innerHTML = '<svg width="20" height="20" viewBox="0 0 0.9 0.9" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M.198.198a.037.037 0 0 1 .053 0L.45.397.648.199a.037.037 0 1 1 .053.053L.503.45l.198.198a.037.037 0 0 1-.053.053L.45.503.252.701A.037.037 0 0 1 .199.648L.397.45.198.252a.037.037 0 0 1 0-.053z" fill="#fff"/></svg>';
91
92 // Check if the player has not been initialized for this wrapper
93 if (playerId && !wrapper.classList.contains('plyr-initialized')) {
94
95
96 let selector = `[data-playerid='${playerId}'] .ose-embedpress-responsive`;
97
98 if (options.self_hosted && options.hosted_format === 'video') {
99 selector = `[data-playerid='${playerId}'] .ose-embedpress-responsive video`;
100 }
101 else if (options.self_hosted && options.hosted_format === 'audio') {
102 selector = `[data-playerid='${playerId}'] .ose-embedpress-responsive audio`;
103 wrapper.style.opacity = "1";
104 }
105
106
107 // Set the main color of the player
108 document.querySelector(`[data-playerid='${playerId}']`).style.setProperty('--plyr-color-main', options.player_color);
109 document.querySelector(`[data-playerid='${playerId}'].custom-player-preset-1, [data-playerid='${playerId}'].custom-player-preset-3, [data-playerid='${playerId}'].custom-player-preset-4`)?.style.setProperty('--plyr-range-fill-background', '#ffffff');
110
111 // Set the poster thumbnail for the player
112 if (document.querySelector(`[data-playerid='${playerId}'] iframe`)) {
113 document.querySelector(`[data-playerid='${playerId}'] iframe`).setAttribute('data-poster', options.poster_thumbnail);
114 }
115 if (document.querySelector(`[data-playerid='${playerId}'] video`)) {
116 document.querySelector(`[data-playerid='${playerId}'] video`).setAttribute('data-poster', options.poster_thumbnail);
117 }
118
119 // Define the controls to be displayed
120 const controls = [
121 'play-large',
122 options.restart ? 'restart' : '',
123 options.rewind ? 'rewind' : '',
124 'play',
125 options.fast_forward ? 'fast-forward' : '',
126 'progress',
127 'current-time',
128 'duration',
129 'mute',
130 'volume',
131 'captions',
132 'settings',
133 options.pip ? 'pip' : '',
134 'airplay',
135 options.download ? 'download' : '',
136 options.fullscreen ? 'fullscreen' : '',
137
138 ].filter(control => control !== '');
139
140 // Create a new Plyr player instance with the specified options and controls
141 const player = new Plyr(selector, {
142 controls: controls,
143 seekTime: 10,
144 poster: options.poster_thumbnail,
145 storage: {
146 enabled: true,
147 key: 'plyr_volume'
148 },
149 displayDuration: true,
150 tooltips: { controls: options.player_tooltip, seek: options.player_tooltip },
151 hideControls: options.hide_controls,
152 youtube: {
153 ...(options.autoplay && { autoplay: options.autoplay }),
154 ...(options.start && { start: options.start }),
155 ...(options.end && { end: options.end }),
156 ...(options.rel && { rel: options.rel }),
157 ...(options.fullscreen && { fs: options.fullscreen })
158 },
159 vimeo: {
160 byline: false,
161 portrait: false,
162 title: false,
163 speed: true,
164 transparent: false,
165 controls: false,
166 ...(options.t && { t: options.t }),
167 ...(options.vautoplay && { autoplay: options.vautoplay }),
168 ...(options.autopause && { autopause: options.autopause }),
169 ...(options.dnt && { dnt: options.dnt }),
170 }
171 });
172
173 playerInit[playerId] = player;
174
175
176
177 // Mark the wrapper as initialized
178 wrapper.classList.add('plyr-initialized');
179
180 const posterElement = wrapper.querySelector('.plyr__poster');
181
182 if (posterElement) {
183 const interval = setInterval(() => {
184 if (posterElement && posterElement.style.backgroundImage) {
185 wrapper.style.opacity = '1';
186 clearInterval(interval);
187 }
188 }, 200);
189
190 }
191
192 }
193
194 // Check for the existence of the player's pip button at regular intervals
195 const pipInterval = setInterval(() => {
196
197 let playerPip = document.querySelector(`[data-playerid="${playerId}"] [data-plyr="pip"]`);
198 if (playerPip) {
199 clearInterval(pipInterval);
200
201 let options = document.querySelector(`[data-playerid="${playerId}"]`).getAttribute('data-options');
202
203 options = JSON.parse(options);
204 if (!options.self_hosted) {
205
206 const iframeSelector = document.querySelector(`[data-playerid="${playerId}"] .plyr__video-wrapper`);
207
208 // Add click event listener to toggle the pip mode
209 playerPip.addEventListener('click', () => {
210 iframeSelector.classList.toggle('pip-mode');
211
212 let parentElement = iframeSelector.parentElement;
213 while (parentElement) {
214 parentElement.style.zIndex = '9999';
215 parentElement = parentElement.parentElement;
216 }
217
218 });
219
220
221 if (options.pip) {
222 iframeSelector.appendChild(pipPlayIconElement);
223 iframeSelector.appendChild(pipPauseIconElement);
224 iframeSelector.appendChild(pipCloseElement);
225 const pipPlay = document.querySelector(`[data-playerid="${playerId}"] .plyr__video-wrapper .pip-play`);
226 const pipPause = document.querySelector(`[data-playerid="${playerId}"] .plyr__video-wrapper .pip-pause`);
227 const pipClose = document.querySelector(`[data-playerid="${playerId}"] .plyr__video-wrapper .pip-close`);
228
229 pipClose.addEventListener('click', () => {
230 iframeSelector.classList.remove('pip-mode');
231 console.log(iframeSelector.classList);
232 });
233
234
235 iframeSelector.addEventListener('click', () => {
236 const ariaPressedValue = document.querySelector(`[data-playerid="${playerId}"] .plyr__controls [data-plyr="play"]`).getAttribute('aria-pressed');
237
238 console.log(ariaPressedValue);
239 if (ariaPressedValue === 'true') {
240 pipPause.style.display = 'none';
241 pipPlay.style.display = 'flex';
242 } else {
243 pipPlay.style.display = 'none';
244 pipPause.style.display = 'flex';
245 }
246 });
247
248 }
249
250
251 }
252 }
253
254 }, 200);
255
256 }
257