mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-20 13:38:05 +02:00
feat(design): Warm Cinema redesign + fast-start players
Full visual overhaul from Cyber-Cinematic Glass to "Warm Cinema": warm charcoal (#0B0908), cream (#F3E9DF), ember (#D9541F). Fraunces (editorial serif) for display, Karla for body/UI. Design - app_colors: new palette, all existing token names preserved, plus posterScrim/heroScrim gradients and lift()/emberFocus() shadows - app_theme: new type scale, tighter radii, 20+ component themes - mobile_theme aligned on the same tokens - glass_container: opaque layered surfaces replace glassmorphism; adds GlassCard (hover + remote-focus states) and CinemaBackdrop - players and boot splash restyled (film-leader motif, no web fonts) Performance - remove every BackdropFilter (33 call sites): backdrop blur forced a full framebuffer read per frame per card, the main scroll jank source - bundle Fraunces/Karla as assets: google_fonts no longer fetches from fonts.gstatic.com at startup - drop the blocking hls.js CDN script from index.html; no Dart code ever used it, only the player iframes need it - self-host hls.js/mpegts.js and load them on demand, so ~213 KB of mpegts is never downloaded for HLS streams - bound image decode size on 10 sites: a 40-poster grid drops from ~240 MB to a few tens of MB of GPU memory Players (new shared engine: web/xf-player-core.js) - event-driven start instead of a 200 ms buffer poll plus a 1.5 s wait - initialLiveManifestSize 3 -> 1, liveSyncDurationCount 10 -> 2, startFragPrefetch on, testBandwidth off - MPEG-TS initial stash 512 KB -> 64 KB - adaptive escalation fast -> balanced -> safe on repeated stalls (60 s rolling window), applied live for HLS so there is no visible cut Pre-existing build breakage fixed along the way - undefined AppColors.shimmer, AppTheme.durationXs and spacing8/12/16/32 - broken relative imports in channel_card and quality_selector_widget - missing GlassCard widget and hasBorder/showShadow parameters Also resolves a leftover unmerged .claude/settings.local.json by keeping the remote version. Still broken (pre-existing, dead code, not reachable from main.dart): recommendations_provider.dart and continue_watching_widget.dart import a models/playlist.dart that no longer exists. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cb5eca7547
commit
6f0f51384a
54 files changed
+2425
-1775
No files matched your search
+83
-47
@@ -1,25 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<base href="$FLUTTER_BASE_HREF">
|
||||
<meta charset="UTF-8">
|
||||
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
|
||||
<meta name="description" content="XtremFlow - Modern IPTV Streaming Application">
|
||||
<meta name="description" content="XtremFlow — streaming IPTV">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="apple-mobile-web-app-title" content="XtremFlow">
|
||||
<meta name="theme-color" content="#0A0E1A">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<title>XtremFlow IPTV</title>
|
||||
<meta name="theme-color" content="#0B0908">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
|
||||
<title>XtremFlow</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="icon" type="image/png" href="favicon.png">
|
||||
<link rel="apple-touch-icon" href="icons/Icon-192.png">
|
||||
<link rel="manifest" href="manifest.json">
|
||||
|
||||
<style>
|
||||
/* =============================================================
|
||||
* Amorce « Warm Cinema » — charbon chaud, crème, braise.
|
||||
* Aucune police web, aucun script tiers : rien ne retarde le boot.
|
||||
* ============================================================= */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
@@ -27,16 +31,15 @@
|
||||
}
|
||||
|
||||
body {
|
||||
background: linear-gradient(135deg, #0F1014 0%, #181920 100%);
|
||||
background: radial-gradient(120% 90% at 22% 0%, #1A1310 0%, #0B0908 62%);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
font-family: 'Inter', 'Roboto', sans-serif;
|
||||
overflow: hidden;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
/* Fullscreen mode - prevent scrollbars */
|
||||
:fullscreen,
|
||||
::backdrop {
|
||||
overflow: hidden !important;
|
||||
@@ -47,68 +50,101 @@
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
.loading-container {
|
||||
.boot {
|
||||
text-align: center;
|
||||
animation: fadeIn 0.5s ease-out;
|
||||
animation: rise 620ms cubic-bezier(0.16, 1, 0.3, 1) both;
|
||||
}
|
||||
|
||||
.logo {
|
||||
font-size: 48px;
|
||||
.mark {
|
||||
font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
|
||||
font-size: clamp(34px, 7vw, 58px);
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.14em;
|
||||
color: #F3E9DF;
|
||||
text-transform: uppercase;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
/* Le « W » d'XtremFlow porte la braise */
|
||||
.mark em {
|
||||
font-style: normal;
|
||||
color: #D9541F;
|
||||
}
|
||||
|
||||
/* Barre d'amorce : balayage lent, comme une pellicule qui se lance */
|
||||
.leader {
|
||||
position: relative;
|
||||
width: min(240px, 56vw);
|
||||
height: 2px;
|
||||
margin: 26px auto 0;
|
||||
background: rgba(243, 233, 223, 0.12);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.leader::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0 auto 0 0;
|
||||
width: 42%;
|
||||
background: linear-gradient(90deg, transparent, #D9541F, transparent);
|
||||
animation: wipe 1150ms cubic-bezier(0.5, 0, 0.5, 1) infinite;
|
||||
}
|
||||
|
||||
.caption {
|
||||
margin-top: 16px;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
background: linear-gradient(135deg, #007AFF 0%, #00C6FF 100%);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
margin-bottom: 24px;
|
||||
letter-spacing: -1px;
|
||||
letter-spacing: 0.32em;
|
||||
text-transform: uppercase;
|
||||
color: rgba(243, 233, 223, 0.38);
|
||||
}
|
||||
|
||||
.spinner {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin: 0 auto 16px;
|
||||
border: 3px solid rgba(0, 122, 255, 0.2);
|
||||
border-top-color: #007AFF;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes wipe {
|
||||
from {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
font-family: 'Outfit', sans-serif;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
transform: translateX(340%);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
@keyframes rise {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
transform: translateY(12px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
|
||||
.boot,
|
||||
.leader::after {
|
||||
animation-duration: 2.4s;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="loading-container">
|
||||
<div class="logo">XtremFlow</div>
|
||||
<div class="spinner"></div>
|
||||
<div class="loading-text">Loading...</div>
|
||||
<div class="boot">
|
||||
<div class="mark">Xtrem<em>Flow</em></div>
|
||||
<div class="leader"></div>
|
||||
<div class="caption">Projection</div>
|
||||
</div>
|
||||
<!-- HLS.js for HLS video playback on Chrome/Firefox -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
|
||||
|
||||
<!--
|
||||
hls.js n'est plus chargé ici. Il était récupéré depuis un CDN de façon
|
||||
BLOQUANTE avant flutter_bootstrap.js alors qu'aucun code Dart ne
|
||||
l'utilise : seuls les iframes de lecture en ont besoin, et elles le
|
||||
chargent désormais elles-mêmes, en local et à la demande.
|
||||
-->
|
||||
<script src="flutter_bootstrap.js" async></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
+71
-339
@@ -1,127 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>XtremFlow Player</title>
|
||||
<!-- HLS.js and mpegts.js for MPEG-TS support -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/hls.js@1.4.12/dist/hls.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/mpegts.js@1.7.3/dist/mpegts.min.js"></script>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
background: #000;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
#player-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#video {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #000;
|
||||
}
|
||||
|
||||
#error {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
font-family: Arial, sans-serif;
|
||||
z-index: 30;
|
||||
}
|
||||
|
||||
#error-icon {
|
||||
font-size: 64px;
|
||||
color: #f44336;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
#loading {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
font-family: Arial, sans-serif;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 4px solid rgba(255, 255, 255, 0.2);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
|
||||
margin: 0 auto 16px;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Safari Autoplay Hint Overlay */
|
||||
#play-overlay {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 90px;
|
||||
height: 90px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
border-radius: 50%;
|
||||
display: none;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
border: 2px solid rgba(255, 255, 255, 0.3);
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
z-index: 25;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
#play-overlay:active {
|
||||
transform: translate(-50%, -50%) scale(0.9);
|
||||
}
|
||||
|
||||
#play-overlay svg {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
fill: white;
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
<!--
|
||||
Les libs hls.js / mpegts.js ne sont PLUS chargées depuis un CDN ni de
|
||||
façon bloquante : xf-player-core.js ne récupère que celle réellement
|
||||
nécessaire au flux courant, en local. Deux requêtes bloquantes en moins
|
||||
et environ 200 Ko de JS jamais téléchargés dans le cas courant.
|
||||
-->
|
||||
<link rel="stylesheet" href="xf-player.css">
|
||||
<link rel="preload" href="vendor/hls.min.js" as="script">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="player-container">
|
||||
<!-- iOS/Safari core attributes -->
|
||||
<video id="video" autoplay playsinline webkit-playsinline preload="auto"></video>
|
||||
|
||||
<div id="play-overlay">
|
||||
@@ -130,243 +24,81 @@
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div id="loading">
|
||||
<div class="spinner"></div>
|
||||
<div id="loading-text">Chargement du flux...</div>
|
||||
<div id="loading" class="xf-center">
|
||||
<div class="xf-leader">
|
||||
<div class="xf-leader-cross"></div>
|
||||
</div>
|
||||
<div class="xf-label" id="loading-text">Ouverture du flux</div>
|
||||
<div class="xf-hint" id="loading-hint"></div>
|
||||
</div>
|
||||
<div id="error">
|
||||
<div id="error-icon">⚠</div>
|
||||
<div id="error-message">Erreur de chargement</div>
|
||||
|
||||
<div id="error" class="xf-center">
|
||||
<div class="xf-error-mark">!</div>
|
||||
<div class="xf-error-title" id="error-message">Erreur de chargement</div>
|
||||
<div class="xf-error-sub">Vérifiez le lien ou votre connexion</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="xf-player-core.js"></script>
|
||||
<script>
|
||||
const video = document.getElementById('video');
|
||||
const loading = document.getElementById('loading');
|
||||
const loadingText = document.getElementById('loading-text');
|
||||
const error = document.getElementById('error');
|
||||
const errorMessage = document.getElementById('error-message');
|
||||
const playOverlay = document.getElementById('play-overlay');
|
||||
(function () {
|
||||
var video = document.getElementById('video');
|
||||
var loading = document.getElementById('loading');
|
||||
var loadingText = document.getElementById('loading-text');
|
||||
var loadingHint = document.getElementById('loading-hint');
|
||||
var errorBox = document.getElementById('error');
|
||||
var errorMessage = document.getElementById('error-message');
|
||||
var playOverlay = document.getElementById('play-overlay');
|
||||
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
let streamUrl = urlParams.get('url');
|
||||
const startTime = parseFloat(urlParams.get('t') || '0');
|
||||
const streamType = urlParams.get('type') || '';
|
||||
const injectedDuration = parseFloat(urlParams.get('duration') || '0');
|
||||
|
||||
function log(msg) { console.log('[Player] ' + msg); }
|
||||
|
||||
function showLoading(msg) {
|
||||
loading.style.display = 'block';
|
||||
loadingText.textContent = msg || 'Chargement du flux...';
|
||||
error.style.display = 'none';
|
||||
}
|
||||
|
||||
function hideLoading() { loading.style.display = 'none'; }
|
||||
|
||||
function showError(message) {
|
||||
hideLoading();
|
||||
error.style.display = 'block';
|
||||
errorMessage.textContent = message || 'Erreur de chargement';
|
||||
playOverlay.style.display = 'none';
|
||||
}
|
||||
|
||||
playOverlay.addEventListener('click', () => {
|
||||
log('Manual play triggered');
|
||||
video.play();
|
||||
playOverlay.style.display = 'none';
|
||||
});
|
||||
|
||||
video.addEventListener('loadedmetadata', () => {
|
||||
if (startTime > 0 && startTime < video.duration) {
|
||||
video.currentTime = startTime;
|
||||
}
|
||||
});
|
||||
|
||||
let lastReportedTime = 0;
|
||||
function reportPosition() {
|
||||
if (video.currentTime > 0 && !video.paused && video.readyState > 2) {
|
||||
if (Math.abs(video.currentTime - lastReportedTime) >= 1) {
|
||||
lastReportedTime = video.currentTime;
|
||||
let duration = video.duration;
|
||||
const hlsDuration = window.currentHlsDuration || 0;
|
||||
if (!isFinite(duration) || isNaN(duration) || duration < 1) {
|
||||
duration = hlsDuration > 0 ? hlsDuration : (injectedDuration > 0 ? injectedDuration : 0);
|
||||
} else if (hlsDuration > duration) {
|
||||
duration = hlsDuration;
|
||||
} else if (injectedDuration > 0 && duration < injectedDuration * 0.9) {
|
||||
duration = injectedDuration;
|
||||
}
|
||||
window.parent.postMessage({ type: 'playback_position', currentTime: video.currentTime, duration: duration }, '*');
|
||||
}
|
||||
}
|
||||
}
|
||||
setInterval(reportPosition, 5000);
|
||||
|
||||
video.addEventListener('pause', () => {
|
||||
window.parent.postMessage({ type: 'playback_status', status: 'paused' }, '*');
|
||||
});
|
||||
|
||||
video.addEventListener('playing', () => {
|
||||
window.parent.postMessage({ type: 'playback_status', status: 'playing' }, '*');
|
||||
hideLoading();
|
||||
playOverlay.style.display = 'none';
|
||||
});
|
||||
|
||||
video.addEventListener('ended', () => {
|
||||
window.parent.postMessage({ type: 'playback_ended', duration: isFinite(video.duration) ? video.duration : injectedDuration }, '*');
|
||||
});
|
||||
|
||||
function reportActivity() { window.parent.postMessage({ type: 'user_activity' }, '*'); }
|
||||
document.addEventListener('mousemove', reportActivity);
|
||||
document.addEventListener('touchstart', reportActivity);
|
||||
document.addEventListener('click', reportActivity);
|
||||
|
||||
window.addEventListener('message', (event) => {
|
||||
const data = event.data;
|
||||
if (!data) return;
|
||||
switch (data.type) {
|
||||
case 'play': video.play().catch(() => playOverlay.style.display = 'flex'); break;
|
||||
case 'pause': video.pause(); break;
|
||||
case 'seek': if (Number.isFinite(data.value)) video.currentTime = data.value; break;
|
||||
case 'set_volume': video.volume = Math.max(0, Math.min(1, data.value)); video.muted = video.volume === 0; break;
|
||||
}
|
||||
});
|
||||
|
||||
async function playWithHLS(url) {
|
||||
log('Trying HLS.js with: ' + url);
|
||||
showLoading('Chargement HLS...');
|
||||
|
||||
if (!Hls.isSupported()) {
|
||||
if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||
video.src = url;
|
||||
video.load();
|
||||
video.play().catch(() => {
|
||||
loading.style.display = 'none';
|
||||
playOverlay.style.display = 'flex';
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
function showLoading(msg) {
|
||||
loading.style.display = 'block';
|
||||
loadingText.textContent = msg || 'Ouverture du flux';
|
||||
errorBox.style.display = 'none';
|
||||
}
|
||||
|
||||
const isTurbo = urlParams.get('turbo') === 'true';
|
||||
const isRecording = urlParams.get('is_recording') === 'true';
|
||||
|
||||
const hlsOptions = {
|
||||
maxBufferLength: 120,
|
||||
enableWorker: true,
|
||||
nudgeOffset: 0.8, // More aggressive jump over corrupted frames
|
||||
nudgeMaxRetries: 30,
|
||||
maxLiveSyncPlaybackRate: 1.1, // Slower catch-up to avoid chaos
|
||||
initialLiveManifestSize: 3, // Wait for more segments before starting
|
||||
abrEwmaDefaultEstimate: 1000000,
|
||||
manifestLoadingRetryDelay: 1000,
|
||||
levelLoadingRetryDelay: 1000
|
||||
};
|
||||
|
||||
// Limit live sync only for actual LIVE IPTV, not recordings
|
||||
if (!isRecording && streamType === 'live') {
|
||||
hlsOptions.liveSyncDurationCount = 10;
|
||||
hlsOptions.liveMaxLatencyDurationCount = 20;
|
||||
function hideLoading() {
|
||||
loading.style.display = 'none';
|
||||
loadingHint.textContent = '';
|
||||
}
|
||||
|
||||
const hls = new Hls(hlsOptions);
|
||||
window.hlsInstance = hls;
|
||||
hls.loadSource(url);
|
||||
hls.attachMedia(video);
|
||||
hls.on(Hls.Events.MANIFEST_PARSED, () => {
|
||||
function showError(msg) {
|
||||
hideLoading();
|
||||
// Wait for a small buffer before playing to avoid chaos
|
||||
const checkBuffer = setInterval(() => {
|
||||
if (video.buffered.length > 0) {
|
||||
const bufferEnd = video.buffered.end(0);
|
||||
if (bufferEnd > 1.5) { // 1.5s buffer-first
|
||||
clearInterval(checkBuffer);
|
||||
video.play().catch(() => playOverlay.style.display = 'flex');
|
||||
}
|
||||
}
|
||||
}, 200);
|
||||
});
|
||||
hls.on(Hls.Events.LEVEL_LOADED, (e, d) => {
|
||||
if (d.details && d.details.totalduration > injectedDuration) window.currentHlsDuration = d.details.totalduration;
|
||||
});
|
||||
hls.on(Hls.Events.ERROR, (e, d) => {
|
||||
if (d.fatal) {
|
||||
if (d.type === Hls.ErrorTypes.NETWORK_ERROR) hls.startLoad();
|
||||
else if (d.type === Hls.ErrorTypes.MEDIA_ERROR) hls.recoverMediaError();
|
||||
else showError('HLS Error: ' + d.details);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
async function playWithMpegTS(url, isLive = true) {
|
||||
log('Trying mpegts.js with: ' + url);
|
||||
showLoading('Chargement MPEG-TS...');
|
||||
if (!mpegts.isSupported()) return false;
|
||||
const player = mpegts.createPlayer({ type: 'mpegts', isLive: isLive, url: url }, {
|
||||
enableWorker: true,
|
||||
stashInitialSize: 512 * 1024, // Buffer-First: 512KB
|
||||
enableStashBuffer: true,
|
||||
liveBufferLatencyChasing: false, // Avoid chaotic catch-up
|
||||
maxStashSize: 30 * 1024 * 1024
|
||||
});
|
||||
player.attachMediaElement(video);
|
||||
player.load();
|
||||
|
||||
// Wait for buffer to fill slightly before playing
|
||||
const checkBuffer = setInterval(() => {
|
||||
if (video.buffered.length > 0) {
|
||||
if (video.buffered.end(0) > 1.0) {
|
||||
clearInterval(checkBuffer);
|
||||
player.play().catch(() => playOverlay.style.display = 'flex');
|
||||
}
|
||||
}
|
||||
}, 200);
|
||||
|
||||
player.on(mpegts.Events.ERROR, (type, detail) => {
|
||||
log('MpegTS Error: ' + type + ' - ' + detail);
|
||||
setTimeout(() => {
|
||||
player.destroy();
|
||||
playWithMpegTS(url, isLive);
|
||||
}, 2000);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
async function playDirect(url) {
|
||||
log('Direct play logic for Safari stability: ' + url);
|
||||
showLoading('Lancement...');
|
||||
video.src = url;
|
||||
video.load();
|
||||
video.play().catch(async () => {
|
||||
log('Direct play blocked, trying fallbacks...');
|
||||
if (url.toLowerCase().includes('.m3u8')) await playWithHLS(url);
|
||||
else playOverlay.style.display = 'flex';
|
||||
});
|
||||
video.addEventListener('canplay', () => hideLoading(), { once: true });
|
||||
video.addEventListener('error', () => showError('Format non supporté'), { once: true });
|
||||
return true;
|
||||
}
|
||||
|
||||
async function initPlayer() {
|
||||
if (!streamUrl) return showError('No URL');
|
||||
const lowerUrl = streamUrl.toLowerCase();
|
||||
if (streamType === 'live') {
|
||||
if (lowerUrl.includes('.m3u8')) await playWithHLS(streamUrl);
|
||||
else await playWithMpegTS(streamUrl, true);
|
||||
} else if (streamType === 'vod') {
|
||||
if (lowerUrl.includes('.m3u8')) await playWithHLS(streamUrl);
|
||||
else await playDirect(streamUrl);
|
||||
} else {
|
||||
if (lowerUrl.includes('.m3u8')) await playWithHLS(streamUrl);
|
||||
else await playDirect(streamUrl);
|
||||
errorBox.style.display = 'block';
|
||||
errorMessage.textContent = msg || 'Erreur de chargement';
|
||||
playOverlay.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
initPlayer();
|
||||
var player = new XFPlayer({
|
||||
video: video,
|
||||
logPrefix: '[Player]',
|
||||
onLoading: showLoading,
|
||||
onReady: function () {
|
||||
hideLoading();
|
||||
playOverlay.style.display = 'none';
|
||||
},
|
||||
onError: showError,
|
||||
onBlocked: function () {
|
||||
hideLoading();
|
||||
playOverlay.style.display = 'flex';
|
||||
},
|
||||
onProfileChange: function (name) {
|
||||
// Retour visuel discret : l'utilisateur comprend pourquoi
|
||||
// la latence augmente légèrement après des coupures.
|
||||
loadingHint.textContent =
|
||||
name === 'safe' ? 'Réseau instable — buffer maximal'
|
||||
: 'Réseau instable — buffer élargi';
|
||||
}
|
||||
});
|
||||
|
||||
playOverlay.addEventListener('click', function () {
|
||||
video.play();
|
||||
playOverlay.style.display = 'none';
|
||||
});
|
||||
|
||||
player.start();
|
||||
window.xfPlayer = player;
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
+70
-326
@@ -1,120 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>IPTV Player Lite</title>
|
||||
<!-- HLS.js and mpegts.js for MPEG-TS support -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/hls.js@1.4.12/dist/hls.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/mpegts.js@1.7.3/dist/mpegts.min.js"></script>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
background: #000;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
#player-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#video {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #000;
|
||||
}
|
||||
|
||||
#error {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
z-index: 30;
|
||||
}
|
||||
|
||||
#error-icon {
|
||||
font-size: 64px;
|
||||
color: #f44336;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
#loading {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 4px solid rgba(255, 255, 255, 0.2);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
|
||||
margin: 0 auto 16px;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Safari Autoplay Hint Overlay */
|
||||
#play-overlay {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
border-radius: 50%;
|
||||
display: none;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
border: 2px solid rgba(255, 255, 255, 0.3);
|
||||
backdrop-filter: blur(8px);
|
||||
-webkit-backdrop-filter: blur(8px);
|
||||
z-index: 25;
|
||||
}
|
||||
|
||||
#play-overlay svg {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
fill: white;
|
||||
margin-left: 4px;
|
||||
}
|
||||
</style>
|
||||
<title>XtremFlow Player Lite</title>
|
||||
<link rel="stylesheet" href="xf-player.css">
|
||||
<link rel="preload" href="vendor/hls.min.js" as="script">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="player-container">
|
||||
<!-- iOS/Safari core attributes -->
|
||||
<video id="video" autoplay playsinline webkit-playsinline preload="auto"></video>
|
||||
|
||||
<div id="play-overlay">
|
||||
@@ -123,238 +18,87 @@
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div id="loading">
|
||||
<div class="spinner"></div>
|
||||
<div id="loading-text">Chargement du flux...</div>
|
||||
<div id="loading" class="xf-center">
|
||||
<div class="xf-leader">
|
||||
<div class="xf-leader-cross"></div>
|
||||
</div>
|
||||
<div class="xf-label" id="loading-text">Ouverture du flux</div>
|
||||
<div class="xf-hint" id="loading-hint"></div>
|
||||
</div>
|
||||
<div id="error">
|
||||
<div id="error-icon">⚠</div>
|
||||
<div id="error-message">Erreur de chargement</div>
|
||||
|
||||
<div id="error" class="xf-center">
|
||||
<div class="xf-error-mark">!</div>
|
||||
<div class="xf-error-title" id="error-message">Erreur de chargement</div>
|
||||
<div class="xf-error-sub">Vérifiez le lien ou votre connexion</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="xf-player-core.js"></script>
|
||||
<script>
|
||||
const video = document.getElementById('video');
|
||||
const loading = document.getElementById('loading');
|
||||
const loadingText = document.getElementById('loading-text');
|
||||
const error = document.getElementById('error');
|
||||
const errorMessage = document.getElementById('error-message');
|
||||
const playOverlay = document.getElementById('play-overlay');
|
||||
(function () {
|
||||
var video = document.getElementById('video');
|
||||
var loading = document.getElementById('loading');
|
||||
var loadingText = document.getElementById('loading-text');
|
||||
var loadingHint = document.getElementById('loading-hint');
|
||||
var errorBox = document.getElementById('error');
|
||||
var errorMessage = document.getElementById('error-message');
|
||||
var playOverlay = document.getElementById('play-overlay');
|
||||
|
||||
// Get parameters from query string
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
let streamUrl = urlParams.get('url');
|
||||
const startTime = parseFloat(urlParams.get('t') || '0');
|
||||
const streamType = urlParams.get('type') || ''; // 'live' or 'vod'
|
||||
|
||||
function log(msg) {
|
||||
console.log('[LitePlayer] ' + msg);
|
||||
}
|
||||
|
||||
function showLoading(msg) {
|
||||
loading.style.display = 'block';
|
||||
loadingText.textContent = msg || 'Chargement du flux...';
|
||||
error.style.display = 'none';
|
||||
}
|
||||
|
||||
function hideLoading() {
|
||||
loading.style.display = 'none';
|
||||
}
|
||||
|
||||
function showError(message) {
|
||||
hideLoading();
|
||||
error.style.display = 'block';
|
||||
errorMessage.textContent = message || 'Erreur de chargement';
|
||||
}
|
||||
|
||||
playOverlay.addEventListener('click', () => {
|
||||
log('Manual play triggered');
|
||||
video.play();
|
||||
playOverlay.style.display = 'none';
|
||||
});
|
||||
|
||||
// Seek to startTime when video is ready
|
||||
video.addEventListener('loadedmetadata', () => {
|
||||
if (startTime > 0 && startTime < video.duration) {
|
||||
video.currentTime = startTime;
|
||||
function showLoading(msg) {
|
||||
loading.style.display = 'block';
|
||||
loadingText.textContent = msg || 'Ouverture du flux';
|
||||
errorBox.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
// Report position to parent
|
||||
let lastReportedTime = 0;
|
||||
function reportPosition() {
|
||||
if (video.currentTime > 0 && !video.paused && video.readyState > 2) {
|
||||
if (Math.abs(video.currentTime - lastReportedTime) >= 5) {
|
||||
lastReportedTime = video.currentTime;
|
||||
window.parent.postMessage({
|
||||
type: 'playback_position',
|
||||
currentTime: video.currentTime,
|
||||
duration: isFinite(video.duration) ? video.duration : 0
|
||||
}, '*');
|
||||
}
|
||||
}
|
||||
}
|
||||
setInterval(reportPosition, 5000);
|
||||
|
||||
video.addEventListener('pause', () => {
|
||||
window.parent.postMessage({ type: 'playback_status', status: 'paused' }, '*');
|
||||
if (video.currentTime === 0 || video.paused) {
|
||||
function hideLoading() {
|
||||
loading.style.display = 'none';
|
||||
playOverlay.style.display = 'flex';
|
||||
}
|
||||
});
|
||||
|
||||
video.addEventListener('playing', () => {
|
||||
window.parent.postMessage({ type: 'playback_status', status: 'playing' }, '*');
|
||||
hideLoading();
|
||||
playOverlay.style.display = 'none';
|
||||
});
|
||||
|
||||
video.addEventListener('ended', () => {
|
||||
window.parent.postMessage({
|
||||
type: 'playback_ended',
|
||||
duration: isFinite(video.duration) ? video.duration : 0
|
||||
}, '*');
|
||||
});
|
||||
|
||||
// Activity reporting
|
||||
function reportActivity() {
|
||||
window.parent.postMessage({ type: 'user_activity' }, '*');
|
||||
}
|
||||
document.addEventListener('mousemove', reportActivity);
|
||||
document.addEventListener('touchstart', reportActivity);
|
||||
document.addEventListener('click', reportActivity);
|
||||
|
||||
async function playWithHLS(url) {
|
||||
log('Trying HLS.js with: ' + url);
|
||||
showLoading('Chargement HLS...');
|
||||
|
||||
if (!Hls.isSupported()) {
|
||||
if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||
video.src = url;
|
||||
video.load();
|
||||
video.play().catch(() => {
|
||||
loading.style.display = 'none';
|
||||
playOverlay.style.display = 'flex';
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
loadingHint.textContent = '';
|
||||
}
|
||||
|
||||
const isTurbo = urlParams.get('turbo') === 'true';
|
||||
|
||||
const hls = new Hls({
|
||||
maxBufferLength: 120,
|
||||
maxMaxBufferLength: 240,
|
||||
enableWorker: true,
|
||||
liveSyncDurationCount: 10,
|
||||
liveMaxLatencyDurationCount: 30,
|
||||
lowLatencyMode: false,
|
||||
nudgeOffset: 0.8,
|
||||
nudgeMaxRetries: 30,
|
||||
maxLiveSyncPlaybackRate: 1.1,
|
||||
initialLiveManifestSize: 3,
|
||||
abrEwmaDefaultEstimate: 1000000,
|
||||
manifestLoadingRetryDelay: 1000,
|
||||
levelLoadingRetryDelay: 1000
|
||||
});
|
||||
|
||||
window.hlsInstance = hls;
|
||||
hls.loadSource(url);
|
||||
hls.attachMedia(video);
|
||||
|
||||
hls.on(Hls.Events.MANIFEST_PARSED, () => {
|
||||
function showError(msg) {
|
||||
hideLoading();
|
||||
const checkBuffer = setInterval(() => {
|
||||
if (video.buffered.length > 0 && video.buffered.end(0) > 1.5) {
|
||||
clearInterval(checkBuffer);
|
||||
video.play().catch(() => playOverlay.style.display = 'flex');
|
||||
}
|
||||
}, 200);
|
||||
});
|
||||
|
||||
hls.on(Hls.Events.ERROR, (event, data) => {
|
||||
if (data.fatal) {
|
||||
if (data.type === Hls.ErrorTypes.NETWORK_ERROR) hls.startLoad();
|
||||
else if (data.type === Hls.ErrorTypes.MEDIA_ERROR) hls.recoverMediaError();
|
||||
else showError('HLS Error: ' + data.details);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async function playWithMpegTS(url, isLive = true) {
|
||||
log('Trying mpegts.js with: ' + url);
|
||||
showLoading('Chargement MPEG-TS...');
|
||||
|
||||
if (!mpegts.isSupported()) return false;
|
||||
|
||||
const isTurbo = urlParams.get('turbo') === 'true';
|
||||
const player = mpegts.createPlayer({
|
||||
type: 'mpegts',
|
||||
isLive: isLive,
|
||||
url: url
|
||||
}, {
|
||||
enableWorker: true,
|
||||
stashInitialSize: 512 * 1024,
|
||||
enableStashBuffer: true,
|
||||
liveBufferLatencyChasing: false,
|
||||
maxStashSize: 30 * 1024 * 1024
|
||||
});
|
||||
|
||||
player.attachMediaElement(video);
|
||||
player.load();
|
||||
|
||||
const checkBuffer = setInterval(() => {
|
||||
if (video.buffered.length > 0 && video.buffered.end(0) > 1.0) {
|
||||
clearInterval(checkBuffer);
|
||||
player.play().catch(() => playOverlay.style.display = 'flex');
|
||||
}
|
||||
}, 200);
|
||||
|
||||
player.on(mpegts.Events.ERROR, (type, detail, info) => {
|
||||
log('MpegTS Error: ' + type + ' - ' + detail);
|
||||
// Auto-recover after 2 seconds
|
||||
setTimeout(() => {
|
||||
try {
|
||||
player.unload();
|
||||
player.detachMediaElement();
|
||||
player.destroy();
|
||||
playWithMpegTS(url, isLive);
|
||||
} catch (e) {
|
||||
showError('MpegTS Recovery Failed');
|
||||
}
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async function initPlayer() {
|
||||
if (!streamUrl) return showError('No URL');
|
||||
log('Stream URL: ' + streamUrl);
|
||||
|
||||
const lowerUrl = streamUrl.toLowerCase();
|
||||
const isHLS = lowerUrl.includes('.m3u8') || lowerUrl.includes('/playlist.m3u8');
|
||||
|
||||
if (isHLS) {
|
||||
await playWithHLS(streamUrl);
|
||||
} else {
|
||||
await playWithMpegTS(streamUrl, streamType === 'live');
|
||||
errorBox.style.display = 'block';
|
||||
errorMessage.textContent = msg || 'Erreur de chargement';
|
||||
playOverlay.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('message', (event) => {
|
||||
const data = event.data;
|
||||
if (data.type === 'play') video.play().catch(() => playOverlay.style.display = 'flex');
|
||||
else if (data.type === 'pause') video.pause();
|
||||
else if (data.type === 'set_volume') { video.volume = Math.max(0, Math.min(1, data.value)); video.muted = video.volume === 0; }
|
||||
});
|
||||
var player = new XFPlayer({
|
||||
video: video,
|
||||
logPrefix: '[LitePlayer]',
|
||||
onLoading: showLoading,
|
||||
onReady: function () {
|
||||
hideLoading();
|
||||
playOverlay.style.display = 'none';
|
||||
},
|
||||
onError: showError,
|
||||
onBlocked: function () {
|
||||
hideLoading();
|
||||
playOverlay.style.display = 'flex';
|
||||
},
|
||||
onProfileChange: function (name) {
|
||||
loadingHint.textContent =
|
||||
name === 'safe' ? 'Réseau instable — buffer maximal'
|
||||
: 'Réseau instable — buffer élargi';
|
||||
}
|
||||
});
|
||||
|
||||
initPlayer();
|
||||
playOverlay.addEventListener('click', function () {
|
||||
video.play();
|
||||
playOverlay.style.display = 'none';
|
||||
});
|
||||
|
||||
// Contrat historique du lite : mise en pause manuelle → overlay lecture.
|
||||
video.addEventListener('pause', function () {
|
||||
if (video.currentTime === 0 || video.paused) {
|
||||
loading.style.display = 'none';
|
||||
playOverlay.style.display = 'flex';
|
||||
}
|
||||
});
|
||||
|
||||
player.start();
|
||||
window.xfPlayer = player;
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
+102
-284
@@ -1,316 +1,134 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="fr">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<title>Mobile IPTV Player</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/hls.js@1.4.12/dist/hls.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/mpegts.js@1.7.3/dist/mpegts.min.js"></script>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
html, body {
|
||||
background: #000;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
#player-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#video {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
background: #000;
|
||||
}
|
||||
|
||||
#loading {
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
color: white;
|
||||
z-index: 20;
|
||||
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.spinner {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.2);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* Unmute button — shown when iOS plays muted */
|
||||
#unmute-btn {
|
||||
display: none;
|
||||
position: absolute;
|
||||
bottom: 32px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
z-index: 30;
|
||||
background: rgba(0, 0, 0, 0.75);
|
||||
color: white;
|
||||
border: 2px solid rgba(255, 255, 255, 0.6);
|
||||
border-radius: 32px;
|
||||
padding: 12px 28px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.5px;
|
||||
cursor: pointer;
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
#unmute-btn:active {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
#error {
|
||||
display: none;
|
||||
position: absolute;
|
||||
color: white;
|
||||
text-align: center;
|
||||
padding: 24px;
|
||||
background: rgba(0, 0, 0, 0.85);
|
||||
border-radius: 16px;
|
||||
z-index: 30;
|
||||
max-width: 80%;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
</style>
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<title>XtremFlow Player Mobile</title>
|
||||
<link rel="stylesheet" href="xf-player.css">
|
||||
<link rel="preload" href="vendor/hls.min.js" as="script">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="player-container">
|
||||
<!-- muted + autoplay: iOS Safari autorise l'autoplay uniquement si muted -->
|
||||
<!-- muted au départ : seul moyen fiable d'obtenir l'autoplay sur iOS -->
|
||||
<video id="video" autoplay muted playsinline webkit-playsinline preload="auto"></video>
|
||||
|
||||
<!-- Bouton son — affiché après démarrage muted sur iOS -->
|
||||
<button id="unmute-btn">🔇 Appuyer pour activer le son</button>
|
||||
|
||||
<div id="loading">
|
||||
<div class="spinner"></div>
|
||||
<div id="l-text" style="font-size: 14px; font-weight: 500;">Chargement...</div>
|
||||
<div id="loading" class="xf-center">
|
||||
<div class="xf-leader">
|
||||
<div class="xf-leader-cross"></div>
|
||||
</div>
|
||||
<div class="xf-label" id="l-text">Ouverture du flux</div>
|
||||
<div class="xf-hint" id="loading-hint"></div>
|
||||
</div>
|
||||
|
||||
<div id="error">
|
||||
<div style="font-size: 40px; margin-bottom: 12px;">⚠️</div>
|
||||
<div id="err-msg" style="font-weight: 600;">Erreur de lecture</div>
|
||||
<div id="err-sub" style="font-size: 12px; color: rgba(255,255,255,0.6); margin-top: 8px;">Vérifiez votre connexion</div>
|
||||
<button id="unmute-btn" class="xf-sound-btn" type="button">
|
||||
<svg viewBox="0 0 24 24">
|
||||
<path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3a4.5 4.5 0 0 0-2.5-4v8a4.5 4.5 0 0 0 2.5-4z" />
|
||||
</svg>
|
||||
Activer le son
|
||||
</button>
|
||||
|
||||
<div id="error" class="xf-center">
|
||||
<div class="xf-error-mark">!</div>
|
||||
<div class="xf-error-title" id="err-msg">Erreur de lecture</div>
|
||||
<div class="xf-error-sub" id="err-sub">Vérifiez votre connexion</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="xf-player-core.js"></script>
|
||||
<script>
|
||||
const video = document.getElementById('video');
|
||||
const loading = document.getElementById('loading');
|
||||
const unmuteBtn = document.getElementById('unmute-btn');
|
||||
const error = document.getElementById('error');
|
||||
(function () {
|
||||
var video = document.getElementById('video');
|
||||
var loading = document.getElementById('loading');
|
||||
var loadingText = document.getElementById('l-text');
|
||||
var loadingHint = document.getElementById('loading-hint');
|
||||
var unmuteBtn = document.getElementById('unmute-btn');
|
||||
var errorBox = document.getElementById('error');
|
||||
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const streamUrl = params.get('url');
|
||||
const streamType = params.get('type') || 'live';
|
||||
var retryCount = 0;
|
||||
var maxRetries = 3;
|
||||
var player = null;
|
||||
|
||||
function log(m) { console.log('[MobilePlayer] ' + m); }
|
||||
function showLoading(msg) {
|
||||
loading.style.display = 'block';
|
||||
loadingText.textContent = msg || 'Ouverture du flux';
|
||||
errorBox.style.display = 'none';
|
||||
}
|
||||
|
||||
let retryCount = 0;
|
||||
const maxRetries = 3;
|
||||
function hideLoading() {
|
||||
loading.style.display = 'none';
|
||||
loadingHint.textContent = '';
|
||||
}
|
||||
|
||||
function showError(code, msg) {
|
||||
loading.style.display = 'none';
|
||||
unmuteBtn.style.display = 'none';
|
||||
error.style.display = 'block';
|
||||
document.getElementById('err-msg').textContent = 'Erreur ' + code;
|
||||
document.getElementById('err-sub').textContent = msg || 'Format non supporté ou lien expiré';
|
||||
}
|
||||
function showError(msg) {
|
||||
hideLoading();
|
||||
unmuteBtn.style.display = 'none';
|
||||
errorBox.style.display = 'block';
|
||||
document.getElementById('err-sub').textContent =
|
||||
msg || 'Format non supporté ou lien expiré';
|
||||
}
|
||||
|
||||
// Bouton son : user gesture DIRECT dans l'iframe → iOS accepte le unmute
|
||||
unmuteBtn.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
video.muted = false;
|
||||
video.volume = 1.0;
|
||||
unmuteBtn.style.display = 'none';
|
||||
log('Unmuted by user');
|
||||
window.parent.postMessage({ type: 'unmuted' }, '*');
|
||||
});
|
||||
|
||||
video.addEventListener('touchend', () => {
|
||||
window.parent.postMessage({ type: 'user_activity' }, '*');
|
||||
});
|
||||
|
||||
video.addEventListener('playing', () => {
|
||||
log('Video playing, muted=' + video.muted);
|
||||
loading.style.display = 'none';
|
||||
retryCount = 0;
|
||||
// Si muted (iOS autoplay), afficher le bouton son
|
||||
if (video.muted) {
|
||||
unmuteBtn.style.display = 'block';
|
||||
// Tenter de démueter automatiquement (fonctionne parfois après interaction)
|
||||
// Le geste utilisateur doit avoir lieu DANS l'iframe : iOS
|
||||
// n'accepte le démutage que dans ce contexte.
|
||||
unmuteBtn.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
video.muted = false;
|
||||
if (video.muted) {
|
||||
// iOS a refusé le unmute automatique — garder le bouton affiché
|
||||
log('Unmute blocked by iOS, showing button');
|
||||
} else {
|
||||
unmuteBtn.style.display = 'none';
|
||||
log('Auto-unmuted successfully');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
video.addEventListener('error', () => {
|
||||
const code = video.error?.code || '?';
|
||||
const msg = video.error?.message || '';
|
||||
log('Video error code=' + code + ' msg=' + msg + ' retry=' + retryCount);
|
||||
|
||||
if (retryCount < maxRetries) {
|
||||
retryCount++;
|
||||
log('Retry ' + retryCount + '/' + maxRetries + ' in 2s');
|
||||
loading.style.display = 'flex';
|
||||
error.style.display = 'none';
|
||||
document.getElementById('l-text').textContent = 'Reconnexion ' + retryCount + '/' + maxRetries + '...';
|
||||
setTimeout(startPlayback, 2000);
|
||||
} else {
|
||||
showError(code, msg);
|
||||
}
|
||||
});
|
||||
|
||||
function startPlayback() {
|
||||
log('startPlayback: ' + streamUrl);
|
||||
video.src = '';
|
||||
video.load();
|
||||
video.src = streamUrl;
|
||||
video.load();
|
||||
video.play().catch(e => {
|
||||
log('play() rejected: ' + e);
|
||||
// Ne pas montrer erreur ici — laisser l'event error gérer
|
||||
video.volume = 1.0;
|
||||
unmuteBtn.style.display = 'none';
|
||||
window.parent.postMessage({ type: 'unmuted' }, '*');
|
||||
});
|
||||
}
|
||||
|
||||
function initHlsJs() {
|
||||
log('Using HLS.js');
|
||||
const hls = new Hls({
|
||||
maxBufferLength: 30,
|
||||
maxMaxBufferLength: 60,
|
||||
liveSyncDurationCount: 5,
|
||||
liveMaxLatencyDurationCount: 10,
|
||||
enableWorker: true,
|
||||
lowLatencyMode: false,
|
||||
nudgeOffset: 0.8,
|
||||
nudgeMaxRetries: 10,
|
||||
manifestLoadingRetryDelay: 1000,
|
||||
levelLoadingRetryDelay: 1000
|
||||
});
|
||||
hls.loadSource(streamUrl);
|
||||
hls.attachMedia(video);
|
||||
hls.on(Hls.Events.MANIFEST_PARSED, () => {
|
||||
log('HLS manifest parsed');
|
||||
video.play().catch(() => log('HLS autoplay blocked'));
|
||||
});
|
||||
hls.on(Hls.Events.ERROR, (e, d) => {
|
||||
log('HLS error type=' + d.type + ' fatal=' + d.fatal);
|
||||
if (d.fatal) {
|
||||
if (d.type === Hls.ErrorTypes.NETWORK_ERROR) hls.startLoad();
|
||||
else if (d.type === Hls.ErrorTypes.MEDIA_ERROR) hls.recoverMediaError();
|
||||
else showError(d.type, 'Erreur HLS fatale');
|
||||
}
|
||||
});
|
||||
}
|
||||
function buildPlayer() {
|
||||
if (player) { try { player.destroy(); } catch (e) {} }
|
||||
|
||||
function initMpegts() {
|
||||
log('Using MpegTS');
|
||||
const player = mpegts.createPlayer({
|
||||
type: 'mpegts',
|
||||
isLive: streamType === 'live',
|
||||
url: streamUrl
|
||||
}, {
|
||||
enableWorker: true,
|
||||
stashInitialSize: 512 * 1024,
|
||||
enableStashBuffer: true,
|
||||
liveBufferLatencyChasing: false,
|
||||
maxStashSize: 30 * 1024 * 1024
|
||||
});
|
||||
player.on(mpegts.Events.ERROR, (type, detail) => {
|
||||
log('MpegTS error type=' + type);
|
||||
showError(type, JSON.stringify(detail));
|
||||
});
|
||||
player.attachMediaElement(video);
|
||||
player.load();
|
||||
player.play().catch(() => log('MpegTS autoplay blocked'));
|
||||
}
|
||||
player = new XFPlayer({
|
||||
video: video,
|
||||
logPrefix: '[MobilePlayer]',
|
||||
onLoading: showLoading,
|
||||
onReady: function () {
|
||||
hideLoading();
|
||||
retryCount = 0;
|
||||
// Tentative de démutage auto ; si iOS refuse, on propose le bouton.
|
||||
if (video.muted) {
|
||||
video.muted = false;
|
||||
unmuteBtn.style.display = video.muted ? 'flex' : 'none';
|
||||
}
|
||||
},
|
||||
onError: function (msg) {
|
||||
if (retryCount < maxRetries) {
|
||||
retryCount++;
|
||||
showLoading('Reconnexion ' + retryCount + '/' + maxRetries);
|
||||
setTimeout(buildPlayer, 1500);
|
||||
} else {
|
||||
showError(msg);
|
||||
}
|
||||
},
|
||||
onBlocked: function () {
|
||||
// Autoplay refusé même en sourdine : le bouton son sert
|
||||
// aussi de déclencheur de lecture.
|
||||
hideLoading();
|
||||
unmuteBtn.style.display = 'flex';
|
||||
},
|
||||
onProfileChange: function (name) {
|
||||
loadingHint.textContent =
|
||||
name === 'safe' ? 'Réseau instable — buffer maximal'
|
||||
: 'Réseau instable — buffer élargi';
|
||||
}
|
||||
});
|
||||
|
||||
function init() {
|
||||
if (!streamUrl) {
|
||||
log('No stream URL');
|
||||
showError('URL', 'Pas de lien de flux');
|
||||
return;
|
||||
}
|
||||
log('Init: ' + streamUrl + ' type=' + streamType);
|
||||
|
||||
const isHLS = streamUrl.toLowerCase().includes('m3u8');
|
||||
const isTS = streamUrl.toLowerCase().endsWith('.ts');
|
||||
log('isHLS=' + isHLS + ' isTS=' + isTS);
|
||||
|
||||
// iOS Safari — HLS natif avec muted autoplay
|
||||
if (isHLS && video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||
log('iOS Safari native HLS (muted autoplay)');
|
||||
startPlayback();
|
||||
return;
|
||||
player.start();
|
||||
window.xfPlayer = player;
|
||||
}
|
||||
|
||||
// Android/Chrome — HLS.js
|
||||
if (isHLS && Hls.isSupported()) {
|
||||
initHlsJs();
|
||||
return;
|
||||
}
|
||||
video.addEventListener('touchend', function () {
|
||||
window.parent.postMessage({ type: 'user_activity' }, '*');
|
||||
}, { passive: true });
|
||||
|
||||
// MpegTS fallback
|
||||
if (mpegts.isSupported()) {
|
||||
initMpegts();
|
||||
return;
|
||||
}
|
||||
|
||||
// Direct fallback
|
||||
log('Direct fallback');
|
||||
startPlayback();
|
||||
}
|
||||
|
||||
// Messages depuis Flutter
|
||||
window.addEventListener('message', (e) => {
|
||||
const d = e.data;
|
||||
if (!d) return;
|
||||
if (d.type === 'play') video.play().catch(() => {});
|
||||
if (d.type === 'pause') video.pause();
|
||||
if (d.type === 'set_volume') {
|
||||
video.muted = d.value === 0;
|
||||
video.volume = d.value;
|
||||
if (d.value > 0) unmuteBtn.style.display = 'none';
|
||||
}
|
||||
});
|
||||
|
||||
init();
|
||||
buildPlayer();
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
!function t(e){var r,i;r=this,i=function(){"use strict";function r(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function i(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?r(Object(i),!0).forEach((function(e){s(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function n(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,m(i.key),i)}}function a(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e,r){return(e=m(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(){return o=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},o.apply(this,arguments)}function l(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,h(t,e)}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}function d(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function c(t,e,r){return c=d()?Reflect.construct.bind():function(t,e,r){var i=[null];i.push.apply(i,e);var n=new(Function.bind.apply(t,i));return r&&h(n,r.prototype),n},c.apply(null,arguments)}function f(t){var e="function"==typeof Map?new Map:void 0;return f=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,i)}function i(){return c(t,arguments,u(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),h(i,t)},f(t)}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}function v(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return g(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function m(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var y={exports:{}};!function(t,e){var r,i,n,a,s;r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(t,e,r){if(r=r||{},t=t.trim(),!(e=e.trim())){if(!r.alwaysNormalize)return t;var n=s.parseURL(t);if(!n)throw new Error("Error trying to parse base URL.");return n.path=s.normalizePath(n.path),s.buildURLFromParts(n)}var a=s.parseURL(e);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):e;var o=s.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=i.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(u.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var h=o.path,d=h.substring(0,h.lastIndexOf("/")+1)+a.path;u.path=s.normalizePath(d)}else u.path=o.path,a.params||(u.params=o.params,a.query||Line truncated
|
||||
//# sourceMappingURL=hls.min.js.map
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Skipped minification because the original files appears to be already minified.
|
||||
* Original file: /npm/mpegts.js@1.7.3/dist/mpegts.js
|
||||
*
|
||||
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
||||
*/
|
||||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.mpegts=t():e.mpegts=t()}(window,(function(){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,i),a.l=!0,a.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)i.d(n,a,function(t){return e[t]}.bind(null,a));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=14)}([function(e,t,i){"use strict";var n=i(6),a=i.n(n),r=function(){function e(){}return e.e=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","error",n),e.ENABLE_ERROR&&(console.error?console.error(n):console.warn?console.warn(n):console.log(n))},e.i=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","info",n),e.ENABLE_INFO&&(console.info?console.info(n):console.log(n))},e.w=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","warn",n),e.ENABLE_WARN&&(console.warn?console.warn(n):console.log(n))},e.d=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","debug",n),e.ENABLE_DEBUG&&(console.debug?console.debug(n):console.log(n))},e.v=function(t,i){t&&!e.FORCE_GLOBAL_TAG||(t=e.GLOBAL_TAG);var n="["+t+"] > "+i;e.ENABLE_CALLBACK&&e.emitter.emit("log","verbose",n),e.ENABLE_VERBOSE&&console.log(n)},e}();r.GLOBAL_TAG="mpegts.js",r.FORCE_GLOBAL_TAG=!1,r.ENABLE_ERROR=!0,r.ENABLE_INFO=!0,r.ENABLE_WARN=!0,r.ENABLE_DEBUG=!0,r.ENABLE_VERBOSE=!0,r.ENABLE_CALLBACK=!1,r.emitter=new a.a,t.a=r},function(e,t,i){"use strict";t.a={IO_ERROR:"io_error",DEMUX_ERROR:"demux_error",INIT_SEGMENT:"init_segment",MEDIA_SEGMENT:"media_segment",LOADING_COMPLETE:"loading_complete",RECOVERED_EARLY_EOF:"recovered_early_eof",MEDIA_INFO:"media_info",METADATA_ARRIVED:"metadata_arrived",SCRIPTDATA_ARRIVED:"scriptdata_arrived",TIMED_ID3_METADATA_ARRIVED:"timed_id3_metadata_arrived",SMPTE2038_METADATA_ARRIVED:"smpte2038_metadata_arrived",SCTE35_METADATA_ARRIVED:"scte35_metadata_arrived",PES_PRIVATE_DATA_DESCRIPTOR:"pes_private_data_descriptor",PES_PRIVATE_DATA_ARRIVED:"pes_private_data_arrived",STATISTICS_INFO:"statistics_info",RECOMMEND_SEEKPOINT:"recommend_seekpoint"}},function(e,t,i){"use strict";i.d(t,"c",(function(){return a})),i.d(t,"b",(function(){return r})),i.d(t,"a",(function(){return s}));var n=i(3),a={kIdle:0,kConnecting:1,kBuffering:2,kError:3,kComplete:4},r={OK:"OK",EXCEPTION:"Exception",HTTP_STATUS_CODE_INVALID:"HttpStatusCodeInvalid",CONNECTING_TIMEOUT:"ConnectingTimeout",EARLY_EOF:"EarlyEof",UNRECOVERABLE_EARLY_EOF:"UnrecoverableEarlyEof"},s=function(){function e(e){this._type=e||"undefined",this._status=a.kIdle,this._needStash=!1,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null}return e.prototype.destroy=function(){this._status=a.kIdle,this._onContentLengthKnown=null,this._onURLRedirect=null,this._onDataArrival=null,this._onError=null,this._onComplete=null},e.prototype.isWorking=function(){return this._status===a.kConnecting||this._status===a.kBuffering},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this._status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"needStashBuffer",{get:function(){return this._needStash},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onContentLengthKnown",{get:function(){return this._onContentLengthKnown},set:function(e){this._onContentLengthKnown=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onURLRedirect",{get:function(){return this._onURLRedirect},set:function(e){this._onURLRedirect=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDataArrival",{get:function(){return this._onDataArrival},set:function(e){this._onDataArrival=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{get:function(){return this._onError},set:function(e){this._onError=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{get:fuLine truncated
|
||||
/*!
|
||||
* @overview es6-promise - a tiny implementation of Promises/A+.
|
||||
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
|
||||
* @license Licensed under MIT license
|
||||
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
|
||||
* @version v4.2.8+1e68dce6
|
||||
*/var n;n=function(){"use strict";function e(e){return"function"==typeof e}var n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},a=0,r=void 0,s=void 0,o=function(e,t){f[a]=e,f[a+1]=t,2===(a+=2)&&(s?s(p):b())},d="undefined"!=typeof window?window:void 0,_=d||{},h=_.MutationObserver||_.WebKitMutationObserver,c="undefined"==typeof self&&void 0!==t&&"[object process]"==={}.toString.call(t),u="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function l(){var e=setTimeout;return function(){return e(p,1)}}var f=new Array(1e3);function p(){for(var e=0;e<a;e+=2)(0,f[e])(f[e+1]),f[e]=void 0,f[e+1]=void 0;a=0}var m,g,v,y,b=void 0;function S(e,t){var i=this,n=new this.constructor(R);void 0===n[A]&&P(n);var a=i._state;if(a){var r=arguments[a-1];o((function(){return I(a,n,r,i._result)}))}else C(i,n,e,t);return n}function E(e){if(e&&"object"==typeof e&&e.constructor===this)return e;var t=new this(R);return L(t,e),t}c?b=function(){return t.nextTick(p)}:h?(g=0,v=new h(p),y=document.createTextNode(""),v.observe(y,{characterData:!0}),b=function(){y.data=g=++g%2}):u?((m=new MessageChannel).port1.onmessage=p,b=function(){return m.port2.postMessage(0)}):b=void 0===d?function(){try{var e=Function("return this")().require("vertx");return void 0!==(r=e.runOnLoop||e.runOnContext)?function(){r(p)}:l()}catch(e){return l()}}():l();var A=Math.random().toString(36).substring(2);function R(){}function T(t,i,n){i.constructor===t.constructor&&n===S&&i.constructor.resolve===E?function(e,t){1===t._state?k(e,t._result):2===t._state?D(e,t._result):C(t,void 0,(function(t){return L(e,t)}),(function(t){return D(e,t)}))}(t,i):void 0===n?k(t,i):e(n)?function(e,t,i){o((function(e){var n=!1,a=function(e,t,i,n){try{e.call(t,i,n)}catch(e){return e}}(i,t,(function(i){n||(n=!0,t!==i?L(e,i):k(e,i))}),(function(t){n||(n=!0,D(e,t))}),e._label);!n&&a&&(n=!0,D(e,a))}),e)}(t,i,n):k(t,i)}function L(e,t){if(e===t)D(e,new TypeError("You cannot resolve a promise with itself"));else if(a=typeof(n=t),null===n||"object"!==a&&"function"!==a)k(e,t);else{var i=void 0;try{i=t.then}catch(t){return void D(e,t)}T(e,t,i)}var n,a}function w(e){e._onerror&&e._onerror(e._result),B(e)}function k(e,t){void 0===e._state&&(e._result=t,e._state=1,0!==e._subscribers.length&&o(B,e))}function D(e,t){void 0===e._state&&(e._state=2,e._result=t,o(w,e))}function C(e,t,i,n){var a=e._subscribers,r=a.length;e._onerror=null,a[r]=t,a[r+1]=i,a[r+2]=n,0===r&&e._state&&o(B,e)}function B(e){var t=e._subscribers,i=e._state;if(0!==t.length){for(var n=void 0,a=void 0,r=e._result,s=0;s<t.length;s+=3)n=t[s],a=t[s+i],n?I(i,n,a,r):a(r);e._subscribers.length=0}}function I(t,i,n,a){var r=e(n),s=void 0,o=void 0,d=!0;if(r){try{s=n(a)}catch(e){d=!1,o=e}if(i===s)return void D(i,new TypeError("A promises callback cannot return that same promise."))}else s=a;void 0!==i._state||(r&&d?L(i,s):!1===d?D(i,o):1===t?k(i,s):2===t&&D(i,s))}var O=0;function P(e){e[A]=O++,e._state=void 0,e._result=void 0,e._subscribers=[]}var M=function(){function e(e,t){this._instanceConstructor=e,this.promise=new e(R),this.promise[A]||P(this.promise),n(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?k(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&k(this.promise,this._result))):D(this.promise,new Error("Array Methods must be provided an Array"))}return e.prototype._enumerate=function(e){for(var t=0;void 0===this._state&&t<e.length;t++)this._eachEntry(e[t],t)},e.prototype._eachEntry=function(e,t){var i=this._instanceConstructor,n=i.resolve;if(n===E){var a=void 0,r=void 0,s=!1;try{a=e.then}catch(e){s=!0,r=e}if(a===S&&void 0!==e._state)this._settledAt(e._state,t,e._result);else if("function"!=typeof a)this._remaining--,this._result[t]=e;else if(i===x){var o=new i(R);s?D(o,r):T(o,e,a),this._willSettleAt(o,t)}else this._willSettleAt(new i((function(t){return t(e)})),t)}else this._willSettleAt(n(e),t)},e.prototype._settledAt=function(e,t,i){var n=this.promise;void 0===n._state&&(this._remaining--,2===e?D(n,i):this._result[t]=i),0===this._remaining&&k(n,this._result)},e.prototype._willSettleAt=function(e,t){var i=this;C(e,void 0,(function(e){return i._settledAt(1,t,e)}),(function(e){return i._settledAt(2,t,e)}))},e}(),x=function(){function t(e){this[A]=O++,this._result=this._state=void 0,this._subscribers=[],R!==e&&("function"!=typeof e&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof t?function(e,t){try{t((function(t){L(e,t)}),(function(t){D(e,t)}))}catch(t){D(e,t)}}(this,e):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return t.prototype.catch=function(e){return this.then(null,e)},t.prototype.finally=function(t){var i=this.constructor;returLine truncated
|
||||
//# sourceMappingURL=mpegts.js.map
|
||||
@@ -0,0 +1,495 @@
|
||||
/* =====================================================================
|
||||
* XtremFlow — Moteur de lecture partagé
|
||||
* ---------------------------------------------------------------------
|
||||
* Objectifs :
|
||||
* 1. ZAP RAPIDE — premier frame le plus tôt possible.
|
||||
* 2. ADAPTATIF — si le réseau décroche, le buffer s'élargit tout seul.
|
||||
* 3. ZÉRO CDN — hls.js / mpegts.js servis en local, chargés à la demande.
|
||||
*
|
||||
* Utilisé par player.html, player_lite.html et player_mobile.html.
|
||||
* ===================================================================== */
|
||||
(function (global) {
|
||||
'use strict';
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Profils de buffer — escalade automatique en cas de micro-coupures
|
||||
// ------------------------------------------------------------------
|
||||
var PROFILES = {
|
||||
// Démarrage : le plus agressif possible.
|
||||
fast: {
|
||||
name: 'fast',
|
||||
hls: {
|
||||
maxBufferLength: 24,
|
||||
maxMaxBufferLength: 60,
|
||||
liveSyncDurationCount: 2,
|
||||
liveMaxLatencyDurationCount: 8,
|
||||
initialLiveManifestSize: 1
|
||||
},
|
||||
mpegtsStash: 64 * 1024
|
||||
},
|
||||
// 2 coupures : on respire.
|
||||
balanced: {
|
||||
name: 'balanced',
|
||||
hls: {
|
||||
maxBufferLength: 60,
|
||||
maxMaxBufferLength: 120,
|
||||
liveSyncDurationCount: 4,
|
||||
liveMaxLatencyDurationCount: 14,
|
||||
initialLiveManifestSize: 2
|
||||
},
|
||||
mpegtsStash: 192 * 1024
|
||||
},
|
||||
// 4 coupures : priorité absolue à la stabilité.
|
||||
safe: {
|
||||
name: 'safe',
|
||||
hls: {
|
||||
maxBufferLength: 120,
|
||||
maxMaxBufferLength: 240,
|
||||
liveSyncDurationCount: 8,
|
||||
liveMaxLatencyDurationCount: 24,
|
||||
initialLiveManifestSize: 3
|
||||
},
|
||||
mpegtsStash: 512 * 1024
|
||||
}
|
||||
};
|
||||
|
||||
var ORDER = ['fast', 'balanced', 'safe'];
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Chargement paresseux des libs (aucune requête inutile)
|
||||
// ------------------------------------------------------------------
|
||||
var _scriptCache = {};
|
||||
|
||||
function loadScript(src) {
|
||||
if (_scriptCache[src]) return _scriptCache[src];
|
||||
_scriptCache[src] = new Promise(function (resolve, reject) {
|
||||
var s = document.createElement('script');
|
||||
s.src = src;
|
||||
s.async = true;
|
||||
s.onload = resolve;
|
||||
s.onerror = function () { reject(new Error('Échec du chargement : ' + src)); };
|
||||
document.head.appendChild(s);
|
||||
});
|
||||
return _scriptCache[src];
|
||||
}
|
||||
|
||||
/** Ouvre la connexion vers l'hôte du flux avant même de connaître l'URL finale. */
|
||||
function preconnect(url) {
|
||||
try {
|
||||
var origin = new URL(url, location.href).origin;
|
||||
if (origin === location.origin) return;
|
||||
['preconnect', 'dns-prefetch'].forEach(function (rel) {
|
||||
var l = document.createElement('link');
|
||||
l.rel = rel;
|
||||
l.href = origin;
|
||||
l.crossOrigin = 'anonymous';
|
||||
document.head.appendChild(l);
|
||||
});
|
||||
} catch (e) { /* URL relative ou invalide : rien à préconnecter */ }
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Moteur
|
||||
// ------------------------------------------------------------------
|
||||
function XFPlayer(options) {
|
||||
this.video = options.video;
|
||||
this.vendorPath = options.vendorPath || 'vendor/';
|
||||
this.logPrefix = options.logPrefix || '[XFPlayer]';
|
||||
|
||||
// Callbacks UI (toutes optionnelles)
|
||||
this.onLoading = options.onLoading || function () {};
|
||||
this.onReady = options.onReady || function () {};
|
||||
this.onError = options.onError || function () {};
|
||||
this.onBlocked = options.onBlocked || function () {};
|
||||
this.onProfileChange = options.onProfileChange || function () {};
|
||||
|
||||
var p = new URLSearchParams(location.search);
|
||||
this.params = p;
|
||||
this.url = options.url || p.get('url');
|
||||
this.type = options.type || p.get('type') || '';
|
||||
this.startTime = parseFloat(p.get('t') || '0');
|
||||
this.injectedDuration = parseFloat(p.get('duration') || '0');
|
||||
this.isRecording = p.get('is_recording') === 'true';
|
||||
|
||||
// Profil de départ : forçable via ?buffer=balanced|safe
|
||||
var forced = p.get('buffer');
|
||||
this.profile = PROFILES[forced] ? PROFILES[forced] : PROFILES.fast;
|
||||
this.profileLocked = !!PROFILES[forced];
|
||||
|
||||
this.hls = null;
|
||||
this.mpegts = null;
|
||||
this._started = false;
|
||||
this._stalls = 0;
|
||||
this._stallTimes = [];
|
||||
this._destroyed = false;
|
||||
this._reportedTime = 0;
|
||||
this._hlsDuration = 0;
|
||||
}
|
||||
|
||||
XFPlayer.prototype.log = function (m) {
|
||||
if (global.console && console.log) console.log(this.logPrefix + ' ' + m);
|
||||
};
|
||||
|
||||
XFPlayer.prototype.send = function (msg) {
|
||||
try { global.parent.postMessage(msg, '*'); } catch (e) {}
|
||||
};
|
||||
|
||||
// ---------------- Démarrage ----------------
|
||||
|
||||
XFPlayer.prototype.start = function () {
|
||||
var self = this;
|
||||
if (!this.url) { this.onError('Aucun flux fourni'); return Promise.resolve(); }
|
||||
|
||||
preconnect(this.url);
|
||||
this._wireVideoEvents();
|
||||
this._wireParentMessages();
|
||||
|
||||
var lower = this.url.toLowerCase();
|
||||
var isHls = lower.indexOf('.m3u8') !== -1;
|
||||
var isLive = this.type === 'live';
|
||||
|
||||
this.onLoading('Ouverture du flux');
|
||||
|
||||
// Safari / iOS : HLS natif = le chemin le plus rapide, aucune lib à charger.
|
||||
if (isHls && this._canPlayNativeHls()) {
|
||||
this.log('HLS natif (Safari/iOS)');
|
||||
return Promise.resolve(this._playDirect(this.url));
|
||||
}
|
||||
|
||||
if (isHls) return this._startHls();
|
||||
if (isLive || lower.indexOf('.ts') !== -1) return this._startMpegts(isLive || true);
|
||||
|
||||
// VOD progressif (mp4, mkv…) : lecture directe.
|
||||
return Promise.resolve(this._playDirect(this.url));
|
||||
};
|
||||
|
||||
XFPlayer.prototype._canPlayNativeHls = function () {
|
||||
return this.video.canPlayType('application/vnd.apple.mpegurl') !== '';
|
||||
};
|
||||
|
||||
// ---------------- HLS ----------------
|
||||
|
||||
XFPlayer.prototype._hlsConfig = function () {
|
||||
var prof = this.profile.hls;
|
||||
return {
|
||||
enableWorker: true,
|
||||
lowLatencyMode: false,
|
||||
|
||||
// ---- Fenêtre de buffer (pilotée par le profil) ----
|
||||
maxBufferLength: prof.maxBufferLength,
|
||||
maxMaxBufferLength: prof.maxMaxBufferLength,
|
||||
backBufferLength: 30,
|
||||
maxBufferSize: 30 * 1000 * 1000,
|
||||
|
||||
// ---- Démarrage rapide ----
|
||||
// 1 seul segment suffit pour commencer (au lieu de 3) : ~2 segments
|
||||
// de latence en moins au zap, soit souvent 4 à 12 secondes gagnées.
|
||||
initialLiveManifestSize: prof.initialLiveManifestSize,
|
||||
startFragPrefetch: true, // précharge le 1er fragment pendant le parse
|
||||
testBandwidth: false, // pas de mesure préalable : on joue tout de suite
|
||||
|
||||
// ---- Live ----
|
||||
liveSyncDurationCount: prof.liveSyncDurationCount,
|
||||
liveMaxLatencyDurationCount: prof.liveMaxLatencyDurationCount,
|
||||
maxLiveSyncPlaybackRate: 1.15,
|
||||
|
||||
// ---- Robustesse ----
|
||||
nudgeOffset: 0.6,
|
||||
nudgeMaxRetries: 20,
|
||||
abrEwmaDefaultEstimate: 2000000,
|
||||
manifestLoadingRetryDelay: 500,
|
||||
levelLoadingRetryDelay: 500,
|
||||
fragLoadingRetryDelay: 500,
|
||||
manifestLoadingMaxRetry: 4,
|
||||
levelLoadingMaxRetry: 4,
|
||||
fragLoadingMaxRetry: 6
|
||||
};
|
||||
};
|
||||
|
||||
XFPlayer.prototype._startHls = function () {
|
||||
var self = this;
|
||||
return loadScript(this.vendorPath + 'hls.min.js').then(function () {
|
||||
if (!global.Hls || !global.Hls.isSupported()) {
|
||||
if (self._canPlayNativeHls()) return self._playDirect(self.url);
|
||||
self.onError('HLS non supporté par ce navigateur');
|
||||
return;
|
||||
}
|
||||
|
||||
var Hls = global.Hls;
|
||||
var hls = new Hls(self._hlsConfig());
|
||||
self.hls = hls;
|
||||
global.hlsInstance = hls; // compat : code existant qui inspecte l'instance
|
||||
|
||||
hls.loadSource(self.url);
|
||||
hls.attachMedia(self.video);
|
||||
|
||||
hls.on(Hls.Events.MANIFEST_PARSED, function () {
|
||||
// Démarrage immédiat : on ne sonde plus le buffer toutes les 200 ms.
|
||||
// Si le réseau ne suit pas, l'escalade de profil s'en chargera.
|
||||
self._attemptPlay();
|
||||
});
|
||||
|
||||
hls.on(Hls.Events.LEVEL_LOADED, function (e, d) {
|
||||
if (d.details && d.details.totalduration > self._hlsDuration) {
|
||||
self._hlsDuration = d.details.totalduration;
|
||||
global.currentHlsDuration = self._hlsDuration;
|
||||
}
|
||||
});
|
||||
|
||||
hls.on(Hls.Events.ERROR, function (e, d) {
|
||||
if (!d.fatal) return;
|
||||
self.log('Erreur HLS fatale : ' + d.details);
|
||||
if (d.type === Hls.ErrorTypes.NETWORK_ERROR) {
|
||||
self._escalate('erreur réseau');
|
||||
hls.startLoad();
|
||||
} else if (d.type === Hls.ErrorTypes.MEDIA_ERROR) {
|
||||
self._escalate('erreur média');
|
||||
hls.recoverMediaError();
|
||||
} else {
|
||||
self.onError('Erreur HLS : ' + d.details);
|
||||
}
|
||||
});
|
||||
}).catch(function (err) {
|
||||
self.onError(err.message);
|
||||
});
|
||||
};
|
||||
|
||||
// ---------------- MPEG-TS ----------------
|
||||
|
||||
XFPlayer.prototype._startMpegts = function (isLive) {
|
||||
var self = this;
|
||||
return loadScript(this.vendorPath + 'mpegts.min.js').then(function () {
|
||||
if (!global.mpegts || !global.mpegts.isSupported()) {
|
||||
return self._playDirect(self.url);
|
||||
}
|
||||
self._createMpegts(isLive);
|
||||
}).catch(function (err) {
|
||||
self.onError(err.message);
|
||||
});
|
||||
};
|
||||
|
||||
XFPlayer.prototype._createMpegts = function (isLive) {
|
||||
var self = this;
|
||||
var mpegts = global.mpegts;
|
||||
|
||||
var player = mpegts.createPlayer(
|
||||
{ type: 'mpegts', isLive: isLive, url: this.url },
|
||||
{
|
||||
enableWorker: true,
|
||||
enableStashBuffer: true,
|
||||
// Le stash initial conditionne directement le délai avant la 1re image.
|
||||
// 64 Ko en profil « fast » contre 512 Ko auparavant.
|
||||
stashInitialSize: this.profile.mpegtsStash,
|
||||
maxStashSize: 30 * 1024 * 1024,
|
||||
liveBufferLatencyChasing: false,
|
||||
lazyLoad: false
|
||||
}
|
||||
);
|
||||
|
||||
this.mpegts = player;
|
||||
this._mpegtsIsLive = isLive;
|
||||
|
||||
player.on(mpegts.Events.ERROR, function (type, detail) {
|
||||
self.log('Erreur MPEG-TS : ' + type + ' / ' + detail);
|
||||
if (self._destroyed) return;
|
||||
self._escalate('erreur MPEG-TS');
|
||||
// Recréation propre avec le nouveau profil.
|
||||
setTimeout(function () {
|
||||
if (self._destroyed) return;
|
||||
try {
|
||||
player.unload();
|
||||
player.detachMediaElement();
|
||||
player.destroy();
|
||||
} catch (e) {}
|
||||
self._createMpegts(self._mpegtsIsLive);
|
||||
}, 1200);
|
||||
});
|
||||
|
||||
player.attachMediaElement(this.video);
|
||||
player.load();
|
||||
this._attemptPlay();
|
||||
};
|
||||
|
||||
// ---------------- Lecture directe ----------------
|
||||
|
||||
XFPlayer.prototype._playDirect = function (url) {
|
||||
var self = this;
|
||||
this.video.src = url;
|
||||
this.video.load();
|
||||
this._attemptPlay();
|
||||
this.video.addEventListener('error', function () {
|
||||
self.onError('Format non supporté');
|
||||
}, { once: true });
|
||||
return true;
|
||||
};
|
||||
|
||||
XFPlayer.prototype._attemptPlay = function () {
|
||||
var self = this;
|
||||
var p = this.video.play();
|
||||
if (p && typeof p.catch === 'function') {
|
||||
p.catch(function () {
|
||||
// Autoplay refusé (Safari/iOS) : on tente en sourdine, sinon overlay.
|
||||
self.video.muted = true;
|
||||
var q = self.video.play();
|
||||
if (q && typeof q.catch === 'function') {
|
||||
q.catch(function () { self.onBlocked(); });
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// ---------------- Escalade adaptative ----------------
|
||||
|
||||
/**
|
||||
* Passe au profil supérieur après des coupures répétées.
|
||||
* Fenêtre glissante de 60 s : deux stalls rapprochés déclenchent l'escalade,
|
||||
* des stalls isolés dans le temps ne pénalisent pas la latence.
|
||||
*/
|
||||
XFPlayer.prototype._escalate = function (reason) {
|
||||
if (this.profileLocked || this._destroyed) return;
|
||||
|
||||
var idx = ORDER.indexOf(this.profile.name);
|
||||
if (idx >= ORDER.length - 1) return; // déjà au maximum
|
||||
|
||||
var next = PROFILES[ORDER[idx + 1]];
|
||||
this.profile = next;
|
||||
this.log('Escalade buffer → ' + next.name + ' (' + reason + ')');
|
||||
this.onProfileChange(next.name, reason);
|
||||
|
||||
// HLS : les fenêtres de buffer sont modifiables à chaud, pas besoin de
|
||||
// recharger le flux — donc aucune coupure visible pour l'utilisateur.
|
||||
if (this.hls) {
|
||||
try {
|
||||
this.hls.config.maxBufferLength = next.hls.maxBufferLength;
|
||||
this.hls.config.maxMaxBufferLength = next.hls.maxMaxBufferLength;
|
||||
this.hls.config.liveSyncDurationCount = next.hls.liveSyncDurationCount;
|
||||
this.hls.config.liveMaxLatencyDurationCount =
|
||||
next.hls.liveMaxLatencyDurationCount;
|
||||
} catch (e) {}
|
||||
}
|
||||
// MPEG-TS : le stash est figé à la création — appliqué à la prochaine
|
||||
// recréation du lecteur (déclenchée par le handler d'erreur).
|
||||
};
|
||||
|
||||
XFPlayer.prototype._noteStall = function () {
|
||||
if (!this._started) return; // les attentes d'amorçage ne comptent pas
|
||||
var now = Date.now();
|
||||
this._stallTimes.push(now);
|
||||
this._stallTimes = this._stallTimes.filter(function (t) {
|
||||
return now - t < 60000;
|
||||
});
|
||||
if (this._stallTimes.length >= 2) {
|
||||
this._stallTimes = [];
|
||||
this._escalate('coupures répétées');
|
||||
}
|
||||
};
|
||||
|
||||
// ---------------- Événements vidéo & pont Flutter ----------------
|
||||
|
||||
XFPlayer.prototype._wireVideoEvents = function () {
|
||||
var self = this;
|
||||
var v = this.video;
|
||||
|
||||
v.addEventListener('loadedmetadata', function () {
|
||||
if (self.startTime > 0 && self.startTime < v.duration) {
|
||||
v.currentTime = self.startTime;
|
||||
}
|
||||
});
|
||||
|
||||
v.addEventListener('playing', function () {
|
||||
self._started = true;
|
||||
self.onReady();
|
||||
self.send({ type: 'playback_status', status: 'playing' });
|
||||
});
|
||||
|
||||
v.addEventListener('pause', function () {
|
||||
self.send({ type: 'playback_status', status: 'paused' });
|
||||
});
|
||||
|
||||
v.addEventListener('waiting', function () { self._noteStall(); });
|
||||
v.addEventListener('stalled', function () { self._noteStall(); });
|
||||
|
||||
v.addEventListener('ended', function () {
|
||||
self.send({
|
||||
type: 'playback_ended',
|
||||
duration: isFinite(v.duration) ? v.duration : self.injectedDuration
|
||||
});
|
||||
});
|
||||
|
||||
// Remontée de position (5 s) — même contrat qu'avant.
|
||||
this._posTimer = setInterval(function () { self._reportPosition(); }, 5000);
|
||||
|
||||
// Activité utilisateur → masquage auto des contrôles côté Flutter.
|
||||
function activity() { self.send({ type: 'user_activity' }); }
|
||||
document.addEventListener('mousemove', activity, { passive: true });
|
||||
document.addEventListener('touchstart', activity, { passive: true });
|
||||
document.addEventListener('click', activity, { passive: true });
|
||||
};
|
||||
|
||||
XFPlayer.prototype._reportPosition = function () {
|
||||
var v = this.video;
|
||||
if (!(v.currentTime > 0) || v.paused || v.readyState <= 2) return;
|
||||
if (Math.abs(v.currentTime - this._reportedTime) < 1) return;
|
||||
this._reportedTime = v.currentTime;
|
||||
|
||||
var duration = v.duration;
|
||||
var hlsDur = this._hlsDuration || 0;
|
||||
if (!isFinite(duration) || isNaN(duration) || duration < 1) {
|
||||
duration = hlsDur > 0 ? hlsDur : (this.injectedDuration > 0 ? this.injectedDuration : 0);
|
||||
} else if (hlsDur > duration) {
|
||||
duration = hlsDur;
|
||||
} else if (this.injectedDuration > 0 && duration < this.injectedDuration * 0.9) {
|
||||
duration = this.injectedDuration;
|
||||
}
|
||||
|
||||
this.send({
|
||||
type: 'playback_position',
|
||||
currentTime: v.currentTime,
|
||||
duration: duration
|
||||
});
|
||||
};
|
||||
|
||||
XFPlayer.prototype._wireParentMessages = function () {
|
||||
var self = this;
|
||||
global.addEventListener('message', function (event) {
|
||||
var d = event.data;
|
||||
if (!d || !d.type) return;
|
||||
var v = self.video;
|
||||
switch (d.type) {
|
||||
case 'play':
|
||||
self._attemptPlay();
|
||||
break;
|
||||
case 'pause':
|
||||
v.pause();
|
||||
break;
|
||||
case 'seek':
|
||||
if (isFinite(d.value)) v.currentTime = d.value;
|
||||
break;
|
||||
case 'set_volume':
|
||||
v.volume = Math.max(0, Math.min(1, d.value));
|
||||
v.muted = v.volume === 0;
|
||||
break;
|
||||
case 'unmute':
|
||||
v.muted = false;
|
||||
if (v.volume === 0) v.volume = 1;
|
||||
break;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
XFPlayer.prototype.destroy = function () {
|
||||
this._destroyed = true;
|
||||
clearInterval(this._posTimer);
|
||||
try { if (this.hls) this.hls.destroy(); } catch (e) {}
|
||||
try {
|
||||
if (this.mpegts) {
|
||||
this.mpegts.unload();
|
||||
this.mpegts.detachMediaElement();
|
||||
this.mpegts.destroy();
|
||||
}
|
||||
} catch (e) {}
|
||||
};
|
||||
|
||||
global.XFPlayer = XFPlayer;
|
||||
global.XFPlayerProfiles = PROFILES;
|
||||
})(window);
|
||||
@@ -0,0 +1,255 @@
|
||||
/* =====================================================================
|
||||
* XtremFlow — Habillage des lecteurs, thème « Warm Cinema »
|
||||
* Charbon chaud (#0B0908), crème (#F3E9DF), braise (#D9541F).
|
||||
*
|
||||
* PERF : aucun backdrop-filter. Le flou de fond force le compositeur à
|
||||
* relire le framebuffer à chaque frame — inacceptable par-dessus une vidéo.
|
||||
* ===================================================================== */
|
||||
|
||||
:root {
|
||||
--xf-ink: #0B0908;
|
||||
--xf-cream: #F3E9DF;
|
||||
--xf-cream-dim: #C5B3A5;
|
||||
--xf-ember: #D9541F;
|
||||
--xf-ember-light: #FFB68C;
|
||||
--xf-danger: #E5484D;
|
||||
--xf-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
background: var(--xf-ink);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
font-family: var(--xf-ui);
|
||||
color: var(--xf-cream);
|
||||
}
|
||||
|
||||
#player-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
background: var(--xf-ink);
|
||||
}
|
||||
|
||||
#video {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: var(--xf-ink);
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------
|
||||
* Amorce de projection — l'anneau de compte à rebours d'une bobine
|
||||
* --------------------------------------------------------------- */
|
||||
.xf-center {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
text-align: center;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
#loading {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.xf-leader {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
margin: 0 auto 20px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Anneau fixe, très discret */
|
||||
.xf-leader::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: 50%;
|
||||
border: 2px solid rgba(243, 233, 223, 0.14);
|
||||
}
|
||||
|
||||
/* Balayage braise */
|
||||
.xf-leader::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: 50%;
|
||||
border: 2px solid transparent;
|
||||
border-top-color: var(--xf-ember);
|
||||
border-right-color: var(--xf-ember);
|
||||
animation: xf-sweep 900ms cubic-bezier(0.5, 0, 0.5, 1) infinite;
|
||||
}
|
||||
|
||||
/* Réticule central : croix d'amorce de pellicule */
|
||||
.xf-leader-cross,
|
||||
.xf-leader-cross::before {
|
||||
position: absolute;
|
||||
background: rgba(243, 233, 223, 0.22);
|
||||
}
|
||||
|
||||
.xf-leader-cross {
|
||||
top: 50%;
|
||||
left: 12px;
|
||||
right: 12px;
|
||||
height: 1px;
|
||||
transform: translateY(-0.5px);
|
||||
}
|
||||
|
||||
.xf-leader-cross::before {
|
||||
content: "";
|
||||
top: -14px;
|
||||
bottom: -14px;
|
||||
left: 50%;
|
||||
width: 1px;
|
||||
height: 28px;
|
||||
transform: translateX(-0.5px);
|
||||
}
|
||||
|
||||
@keyframes xf-sweep {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.xf-label {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.18em;
|
||||
text-transform: uppercase;
|
||||
color: var(--xf-cream-dim);
|
||||
}
|
||||
|
||||
/* Mention discrète quand le buffer s'élargit tout seul */
|
||||
.xf-hint {
|
||||
margin-top: 10px;
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.08em;
|
||||
color: rgba(243, 233, 223, 0.42);
|
||||
min-height: 14px;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------
|
||||
* Erreur
|
||||
* --------------------------------------------------------------- */
|
||||
#error {
|
||||
display: none;
|
||||
max-width: 78vw;
|
||||
}
|
||||
|
||||
.xf-error-mark {
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
margin: 0 auto 18px;
|
||||
border: 2px solid var(--xf-danger);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 26px;
|
||||
line-height: 1;
|
||||
color: var(--xf-danger);
|
||||
}
|
||||
|
||||
.xf-error-title {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.02em;
|
||||
color: var(--xf-cream);
|
||||
}
|
||||
|
||||
.xf-error-sub {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.04em;
|
||||
color: rgba(243, 233, 223, 0.5);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------
|
||||
* Overlay lecture (autoplay bloqué)
|
||||
* --------------------------------------------------------------- */
|
||||
#play-overlay {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 92px;
|
||||
height: 92px;
|
||||
border-radius: 50%;
|
||||
background: rgba(11, 9, 8, 0.82);
|
||||
border: 2px solid var(--xf-ember);
|
||||
box-shadow: 0 0 40px rgba(217, 84, 31, 0.35);
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
z-index: 25;
|
||||
transition: transform 160ms cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
#play-overlay:hover {
|
||||
transform: translate(-50%, -50%) scale(1.06);
|
||||
}
|
||||
|
||||
#play-overlay:active {
|
||||
transform: translate(-50%, -50%) scale(0.94);
|
||||
}
|
||||
|
||||
#play-overlay svg {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
fill: var(--xf-cream);
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------
|
||||
* Bouton « activer le son » (iOS)
|
||||
* --------------------------------------------------------------- */
|
||||
.xf-sound-btn {
|
||||
position: absolute;
|
||||
bottom: 26px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
display: none;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
padding: 12px 22px;
|
||||
border: 1px solid var(--xf-ember);
|
||||
border-radius: 999px;
|
||||
background: rgba(11, 9, 8, 0.88);
|
||||
color: var(--xf-cream);
|
||||
font-family: var(--xf-ui);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.14em;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
z-index: 26;
|
||||
}
|
||||
|
||||
.xf-sound-btn svg {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
fill: var(--xf-ember-light);
|
||||
}
|
||||
|
||||
/* Respect des préférences d'accessibilité */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.xf-leader::after {
|
||||
animation-duration: 2s;
|
||||
}
|
||||
|
||||
#play-overlay {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user