web: force hls.js archive playback on chromium
This commit is contained in:
parent
cc5cf0be3b
commit
1b300d2e1e
2 changed files with 33 additions and 1 deletions
|
|
@ -219,6 +219,17 @@ async function ensureHlsPlayerCtor() {
|
|||
return hlsModulePromise;
|
||||
}
|
||||
|
||||
function shouldUseNativeHls(video) {
|
||||
const ua = navigator.userAgent || "";
|
||||
const vendor = navigator.vendor || "";
|
||||
const isIos = /iPhone|iPad|iPod/i.test(ua);
|
||||
const isSafari =
|
||||
/Safari/i.test(ua) &&
|
||||
/Apple/i.test(vendor) &&
|
||||
!/CriOS|FxiOS|EdgiOS|OPiOS|Chrome|Chromium/i.test(ua);
|
||||
return (isIos || isSafari) && Boolean(video.canPlayType("application/vnd.apple.mpegurl"));
|
||||
}
|
||||
|
||||
async function mountArchivePlayer(name) {
|
||||
clearPlayerSignals();
|
||||
destroyArchivePlayer();
|
||||
|
|
@ -241,7 +252,7 @@ async function mountArchivePlayer(name) {
|
|||
mount.appendChild(video);
|
||||
|
||||
const archiveUrl = `/api/archive/${encodeURIComponent(name)}/master.m3u8`;
|
||||
if (video.canPlayType("application/vnd.apple.mpegurl")) {
|
||||
if (shouldUseNativeHls(video)) {
|
||||
video.src = archiveUrl;
|
||||
void video.play().catch(() => {});
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue