Fix Facebook in-app browser playback and document www SSL setup.
Mute autoplay and add faster loader fallback for FB/Instagram WebViews; document adding www.slavic-pulse.com in Dokploy to avoid self-signed cert errors on mobile. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+22
-8
@@ -168,6 +168,7 @@
|
||||
redirectEnabled: ${POST_VIDEO_REDIRECT_ENABLED_VERTICAL_JS}
|
||||
}
|
||||
};
|
||||
const SITE_ORIGIN = '${SITE_BASE_URL}';
|
||||
let player;
|
||||
let activeFormat;
|
||||
let activeConfig;
|
||||
@@ -176,6 +177,15 @@
|
||||
const stageVideo = document.getElementById('stage-video');
|
||||
const stage = document.getElementById('stage');
|
||||
|
||||
function isInAppBrowser() {
|
||||
const ua = navigator.userAgent || '';
|
||||
return /FBAN|FBAV|Instagram|Line\/|Twitter|LinkedInApp|wv\)/i.test(ua);
|
||||
}
|
||||
|
||||
function hideLoader() {
|
||||
loader.classList.add('hidden');
|
||||
}
|
||||
|
||||
function youtubeThumbnailUrl(videoId, quality) {
|
||||
return 'https://img.youtube.com/vi/' + videoId + '/' + (quality || 'maxresdefault') + '.jpg';
|
||||
}
|
||||
@@ -240,15 +250,21 @@
|
||||
|
||||
const stageBg = document.getElementById('stage-bg');
|
||||
const bgPreload = new Image();
|
||||
bgPreload.onload = () => loader.classList.add('hidden');
|
||||
bgPreload.onload = hideLoader;
|
||||
bgPreload.onerror = hideLoader;
|
||||
if (stageBg && stageBg.src) {
|
||||
bgPreload.src = stageBg.src;
|
||||
} else {
|
||||
hideLoader();
|
||||
}
|
||||
|
||||
const tag = document.createElement('script');
|
||||
tag.src = 'https://www.youtube.com/iframe_api';
|
||||
tag.onerror = hideLoader;
|
||||
document.head.appendChild(tag);
|
||||
|
||||
setTimeout(hideLoader, isInAppBrowser() ? 4000 : 15000);
|
||||
|
||||
function enableVideoSound() {
|
||||
if (!player || typeof player.unMute !== 'function') return;
|
||||
player.unMute();
|
||||
@@ -264,7 +280,7 @@
|
||||
videoId: activeConfig.id,
|
||||
playerVars: {
|
||||
autoplay: 1,
|
||||
mute: 0,
|
||||
mute: 1,
|
||||
controls: 0,
|
||||
showinfo: 0,
|
||||
modestbranding: 1,
|
||||
@@ -274,7 +290,7 @@
|
||||
disablekb: 1,
|
||||
iv_load_policy: 3,
|
||||
cc_load_policy: 0,
|
||||
origin: window.location.origin
|
||||
origin: SITE_ORIGIN.replace(/\/$/, '')
|
||||
},
|
||||
events: {
|
||||
onReady: onPlayerReady,
|
||||
@@ -285,9 +301,11 @@
|
||||
|
||||
function onPlayerReady(event) {
|
||||
sizeVideoCover();
|
||||
enableVideoSound();
|
||||
stageVideo.classList.add('active');
|
||||
event.target.playVideo();
|
||||
if (!isInAppBrowser()) {
|
||||
enableVideoSound();
|
||||
}
|
||||
}
|
||||
|
||||
function onPlayerStateChange(event) {
|
||||
@@ -315,10 +333,6 @@
|
||||
window.addEventListener('resize', handleResize);
|
||||
|
||||
document.getElementById('stage-root').addEventListener('pointerdown', enableVideoSound, { once: true });
|
||||
|
||||
setTimeout(() => {
|
||||
loader.classList.add('hidden');
|
||||
}, 15000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user