VisionQuest-Vj Neil
Episode episode 2
// Direct video file
if (directVideoExts.includes(ext)) {
const video = makeNativeVideo();
video.src = url;
const doFallback = function() {
if (iframeFallbackWorthy.includes(ext)) {
fallbackToIframe();
} else {
fallbackToDownload(ext);
}
};
video.addEventListener('error', doFallback, { once: true });
// Several formats (MKV, AVI, WMV, FLV, TS...) have inconsistent
// browser support and sometimes fail silently — no error event,
// it just never starts. If playback hasn't begun within a few
// seconds, treat that as a failure and fall back.
const flakyExts = ['mkv', 'avi', 'flv', 'wmv', 'ts', 'm2ts', 'mts', '3gp', '3g2', 'f4v'];
if (flakyExts.includes(ext)) {
let started = false;
video.addEventListener('playing', function() { started = true; }, { once: true });
setTimeout(function() {
if (!started) doFallback();
}, 4000);
}
playerHost.appendChild(video);
return;
}
// Fallback: treat as a generic embeddable URL (embed codes, other players, etc.)
playerHost.appendChild(makeIframe(url));
}
initPlayer(videoUrl);
})();