mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-18 04:39:41 +02:00
fix(player): resolve Safari infinite loading by refining play overlay and loading logic
This commit is contained in:
1 parent
dbb6559640
commit
a256ca87b6
3 files changed
+14
-10
No files matched your search
+4
-2
@@ -205,7 +205,6 @@
|
|||||||
|
|
||||||
video.addEventListener('pause', () => {
|
video.addEventListener('pause', () => {
|
||||||
window.parent.postMessage({ type: 'playback_status', status: 'paused' }, '*');
|
window.parent.postMessage({ type: 'playback_status', status: 'paused' }, '*');
|
||||||
if (loading.style.display === 'none') playOverlay.style.display = 'flex';
|
|
||||||
});
|
});
|
||||||
|
|
||||||
video.addEventListener('playing', () => {
|
video.addEventListener('playing', () => {
|
||||||
@@ -242,7 +241,10 @@
|
|||||||
if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||||
video.src = url;
|
video.src = url;
|
||||||
video.load();
|
video.load();
|
||||||
video.play().catch(() => playOverlay.style.display = 'flex');
|
video.play().catch(() => {
|
||||||
|
loading.style.display = 'none';
|
||||||
|
playOverlay.style.display = 'flex';
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -198,7 +198,8 @@
|
|||||||
|
|
||||||
video.addEventListener('pause', () => {
|
video.addEventListener('pause', () => {
|
||||||
window.parent.postMessage({ type: 'playback_status', status: 'paused' }, '*');
|
window.parent.postMessage({ type: 'playback_status', status: 'paused' }, '*');
|
||||||
if (loading.style.display === 'none') {
|
if (video.currentTime === 0 || video.paused) {
|
||||||
|
loading.style.display = 'none';
|
||||||
playOverlay.style.display = 'flex';
|
playOverlay.style.display = 'flex';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -232,7 +233,10 @@
|
|||||||
if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||||
video.src = url;
|
video.src = url;
|
||||||
video.load();
|
video.load();
|
||||||
video.play().catch(() => playOverlay.style.display = 'flex');
|
video.play().catch(() => {
|
||||||
|
loading.style.display = 'none';
|
||||||
|
playOverlay.style.display = 'flex';
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -188,16 +188,13 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
video.addEventListener('pause', () => {
|
video.addEventListener('pause', () => {
|
||||||
// Only show play overlay if not loading
|
// If we're paused and not playing, and it looks like it was blocked or stopped
|
||||||
if (loading.style.display === 'none') {
|
if (video.currentTime === 0 || video.paused) {
|
||||||
|
loading.style.display = 'none';
|
||||||
playOverlay.style.display = 'flex';
|
playOverlay.style.display = 'flex';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
video.addEventListener('waiting', () => {
|
|
||||||
loading.style.display = 'flex';
|
|
||||||
playOverlay.style.display = 'none';
|
|
||||||
});
|
|
||||||
|
|
||||||
video.addEventListener('error', () => {
|
video.addEventListener('error', () => {
|
||||||
loading.style.display = 'none';
|
loading.style.display = 'none';
|
||||||
@@ -222,6 +219,7 @@
|
|||||||
video.load();
|
video.load();
|
||||||
video.play().catch(e => {
|
video.play().catch(e => {
|
||||||
log('Autoplay blocked by Safari, showing overlay');
|
log('Autoplay blocked by Safari, showing overlay');
|
||||||
|
loading.style.display = 'none';
|
||||||
playOverlay.style.display = 'flex';
|
playOverlay.style.display = 'flex';
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in new issue
Block a user