edited230126
This commit is contained in:
@@ -82,6 +82,18 @@
|
||||
el.src = item.url;
|
||||
stage.appendChild(el);
|
||||
timer = setTimeout(next, (item.duration || 10) * 1000);
|
||||
} else if (item.type === 'youtube') {
|
||||
const el = document.createElement('iframe');
|
||||
// item.url is a base embed URL produced server-side (https://www.youtube-nocookie.com/embed/<id>)
|
||||
// Add common playback params client-side.
|
||||
const u = item.url || '';
|
||||
const sep = u.includes('?') ? '&' : '?';
|
||||
el.src = `${u}${sep}autoplay=1&mute=1&controls=0&rel=0&playsinline=1`;
|
||||
stage.appendChild(el);
|
||||
|
||||
// YouTube iframes don't reliably emit an "ended" event without the JS API.
|
||||
// We keep it simple: play for the configured duration (default 30s).
|
||||
timer = setTimeout(next, (item.duration || 30) * 1000);
|
||||
} else {
|
||||
timer = setTimeout(next, 5000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user