diff --git a/internal/webui/player-capabilities.js b/internal/webui/player-capabilities.js index 796fe83..5adf798 100644 --- a/internal/webui/player-capabilities.js +++ b/internal/webui/player-capabilities.js @@ -25,7 +25,10 @@ const supported = type => playable(type) || mse(type); const videoCodecs = {h264: 'avc1.42E01E', hevc: 'hvc1.1.6.L120.B0', av1: 'av01.0.08M.08', vp9: 'vp09.00.10.08'}; const audioCodecs = {aac: 'mp4a.40.2', mp3: 'mp4a.69', ac3: 'ac-3', eac3: 'ec-3', opus: 'opus'}; - return {mp4: playable('video/mp4'), nativeHls: native(), hlsjs: Boolean(environment.Hls?.isSupported()), + // iOS 上的第三方浏览器(Chrome/Firefox/Edge/Opera)自带的媒体栈对 fMP4 HLS 兼容性差, + // 会黑屏缓冲;让服务端按无 HLS 通道规划,走 legacy 的 TS 实时转码(hls/open)。 + const thirdPartyIOS = touchApple && /CriOS|FxiOS|EdgiOS|OPT\//.test(agent.userAgent || ''); + return {mp4: playable('video/mp4'), nativeHls: native() && !thirdPartyIOS, hlsjs: Boolean(environment.Hls?.isSupported()), video: Object.keys(videoCodecs).filter(key => supported('video/mp4; codecs="' + videoCodecs[key] + '"')), audio: Object.keys(audioCodecs).filter(key => supported('audio/mp4; codecs="' + audioCodecs[key] + '"'))}; } diff --git a/internal/webui/player-capabilities.test.cjs b/internal/webui/player-capabilities.test.cjs index 61b2a45..3464f38 100644 --- a/internal/webui/player-capabilities.test.cjs +++ b/internal/webui/player-capabilities.test.cjs @@ -33,3 +33,17 @@ test('remux requires compatible H.264 profiles and never replaces iOS HLS', () = limited.MediaSource.isTypeSupported = () => {throw new Error('probe unavailable');}; assert.equal(capabilities(limited, native, {}).remux(), false); }); + +test('third-party iOS browsers hide native HLS so the server plans the TS path', () => { + for (const ua of ['iPhone CriOS/154.0.8037.41 Mobile/15E148 Safari/604.1', + 'iPhone FxiOS/130.0 Mobile/15E148 Safari/605.1.15', + 'iPhone EdgiOS/130.0.1 Mobile/15E148 Safari/605.1.15']) { + const view = capabilities(mse(true), native, {userAgent: ua}); + assert.equal(view.describe().nativeHls, false); + assert.equal(view.choose(type), 'hls'); + } + const safari = capabilities(mse(true), native, {userAgent: 'iPhone Version/27.0 Mobile/15E148 Safari/604.1'}); + assert.equal(safari.describe().nativeHls, true); + const opera = capabilities(mse(true), native, {userAgent: 'iPhone OPT/2.4.0 Mobile/15E148 Safari/605.1.15'}); + assert.equal(opera.describe().nativeHls, false); +});