PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.0.2
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.0.2
4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 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
245 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 }
104
105
106 // Set the main color of the player
107 document.querySelector(`[data-playerid='${playerId}']`).style.setProperty('--plyr-color-main', options.player_color);
108 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');
109
110 // Set the poster thumbnail for the player
111 if (document.querySelector(`[data-playerid='${playerId}'] iframe`)) {
112 document.querySelector(`[data-playerid='${playerId}'] iframe`).setAttribute('data-poster', options.poster_thumbnail);
113 }
114
115
116 // Define the controls to be displayed
117 const controls = [
118 'play-large',
119 options.restart ? 'restart' : '',
120 options.rewind ? 'rewind' : '',
121 'play',
122 options.fast_forward ? 'fast-forward' : '',
123 'progress',
124 'current-time',
125 'duration',
126 'mute',
127 'volume',
128 'captions',
129 'settings',
130 options.pip ? 'pip' : '',
131 'airplay',
132 options.download ? 'download' : '',
133 options.fullscreen ? 'fullscreen' : '',
134
135 ].filter(control => control !== '');
136
137 // Create a new Plyr player instance with the specified options and controls
138 const player = new Plyr(selector, {
139 controls: controls,
140 seekTime: 10,
141 poster: options.poster_thumbnail,
142 storage: {
143 enabled: true,
144 key: 'plyr_volume'
145 },
146 displayDuration: true,
147 tooltips: { controls: options.player_tooltip, seek: options.player_tooltip },
148 hideControls: options.hide_controls,
149 youtube: {
150 ...(options.autoplay && { autoplay: options.autoplay }),
151 ...(options.start && { start: options.start }),
152 ...(options.end && { end: options.end }),
153 ...(options.rel && { rel: options.rel }),
154 ...(options.fullscreen && { fs: options.fullscreen })
155 },
156 vimeo: {
157 byline: false,
158 portrait: false,
159 title: false,
160 speed: true,
161 transparent: false,
162 controls: false,
163 ...(options.t && { t: options.t }),
164 ...(options.vautoplay && { autoplay: options.vautoplay }),
165 ...(options.autopause && { autopause: options.autopause }),
166 ...(options.dnt && { dnt: options.dnt }),
167 }
168 });
169
170 playerInit[playerId] = player;
171
172
173
174 // Mark the wrapper as initialized
175 wrapper.classList.add('plyr-initialized');
176
177 if (wrapper.querySelector('.plyr__poster')) {
178 wrapper.style.opacity = '1';
179 }
180 }
181
182 // Check for the existence of the player's pip button at regular intervals
183 const pipInterval = setInterval(() => {
184
185 let playerPip = document.querySelector(`[data-playerid="${playerId}"] [data-plyr="pip"]`);
186 if (playerPip) {
187 clearInterval(pipInterval);
188
189 let options = document.querySelector(`[data-playerid="${playerId}"]`).getAttribute('data-options');
190
191 options = JSON.parse(options);
192 if (!options.self_hosted) {
193
194 const iframeSelector = document.querySelector(`[data-playerid="${playerId}"] .plyr__video-wrapper`);
195
196 // Add click event listener to toggle the pip mode
197 playerPip.addEventListener('click', () => {
198 iframeSelector.classList.toggle('pip-mode');
199
200 let parentElement = iframeSelector.parentElement;
201 while (parentElement) {
202 parentElement.style.zIndex = '9999';
203 parentElement = parentElement.parentElement;
204 }
205
206 });
207
208
209 if (options.pip) {
210 iframeSelector.appendChild(pipPlayIconElement);
211 iframeSelector.appendChild(pipPauseIconElement);
212 iframeSelector.appendChild(pipCloseElement);
213 const pipPlay = document.querySelector(`[data-playerid="${playerId}"] .plyr__video-wrapper .pip-play`);
214 const pipPause = document.querySelector(`[data-playerid="${playerId}"] .plyr__video-wrapper .pip-pause`);
215 const pipClose = document.querySelector(`[data-playerid="${playerId}"] .plyr__video-wrapper .pip-close`);
216
217 pipClose.addEventListener('click', () => {
218 iframeSelector.classList.remove('pip-mode');
219 console.log(iframeSelector.classList);
220 });
221
222
223 iframeSelector.addEventListener('click', () => {
224 const ariaPressedValue = document.querySelector(`[data-playerid="${playerId}"] .plyr__controls [data-plyr="play"]`).getAttribute('aria-pressed');
225
226 console.log(ariaPressedValue);
227 if (ariaPressedValue === 'true') {
228 pipPause.style.display = 'none';
229 pipPlay.style.display = 'flex';
230 } else {
231 pipPlay.style.display = 'none';
232 pipPause.style.display = 'flex';
233 }
234 });
235
236 }
237
238
239 }
240 }
241
242 }, 200);
243
244 }
245