openvibers/openvibe.mediahub Commits

Native HLS plays in CORS mode, with the file as its fallback (offloaded segments failed to parse: VOD 5925 stopped at 1:23:35) (#117)

OP OpenVibers committed 21 days ago · cbf2636544 · 1 file, +13 −0

Changes

ddiff --git a/public/js/video.js b/public/js/video.js
iindex 711ba69..8a3557a 100644
---- a/public/js/video.js
++++ b/public/js/video.js
@@@ -40,7 +40,20 @@
const fileUrl = video.getAttribute('src');
if (!hlsUrl || !fileUrl) return Promise.resolve('file');
if (video.canPlayType('application/vnd.apple.mpegurl')) {
++ // Native HLS (Safari, iOS, and Chrome since it plays HLS itself) fetches segments as the element does. A
++ // segment Media moved to its object store redirects to another origin, which plays only in CORS mode: in
++ // no-cors mode Chrome could not parse it (VOD 5925 stopped at 1:23:35 on 2026-10-23). Media and its store
++ // both answer CORS. If the playlist still fails, the file plays from the same position, without CORS (its
++ // edge sends no CORS header), once.
++ video.crossOrigin = 'anonymous';
video.src = hlsUrl;
++ video.addEventListener('error', function fallback() {
++ video.removeEventListener('error', fallback);
++ const at = video.currentTime || 0;
++ video.removeAttribute('crossorigin');
++ video.src = fileUrl;
++ if (at > 0) seek(video, at);
++ });
return Promise.resolve('hls');
}
if (!window.MediaSource) return Promise.resolve('file');