|
|
|
@ -14,6 +14,21 @@ const PLAY_RETRY_MAX = 3 |
|
|
|
const PLAY_EXPIRE_FALLBACK_SEC = 270 |
|
|
|
const PLAY_REFRESH_LEAD_MS = 30_000 |
|
|
|
|
|
|
|
function isFatalPlayMediaError(err) { |
|
|
|
const msg = String(err?.message || err || '').toLowerCase() |
|
|
|
const name = String(err?.name || '') |
|
|
|
return ( |
|
|
|
name === 'SecurityError' || |
|
|
|
msg.includes('ssl') || |
|
|
|
msg.includes('tls') || |
|
|
|
msg.includes('cipher') || |
|
|
|
msg.includes('err_ssl') || |
|
|
|
msg.includes('mixed content') || |
|
|
|
msg.includes('cors') || |
|
|
|
msg.includes('certificate') |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
export function useMonitorLive({ getDockId, ui, getLivePlayer }) { |
|
|
|
const live = reactive({ |
|
|
|
session: null, |
|
|
|
@ -59,6 +74,15 @@ export function useMonitorLive({ getDockId, ui, getLivePlayer }) { |
|
|
|
live.phasePollStartedAt = 0 |
|
|
|
} |
|
|
|
|
|
|
|
function markPlayFatal(message) { |
|
|
|
window.clearTimeout(live.playRefreshTimer) |
|
|
|
live.playRefreshTimer = null |
|
|
|
live.playUrl = '' |
|
|
|
live.playUrlExpiresAt = 0 |
|
|
|
live.playRetryCount = PLAY_RETRY_MAX |
|
|
|
ui.toast(message) |
|
|
|
} |
|
|
|
|
|
|
|
function toggleLive() { |
|
|
|
if (live.session) closeLive() |
|
|
|
else openLive() |
|
|
|
@ -197,21 +221,35 @@ export function useMonitorLive({ getDockId, ui, getLivePlayer }) { |
|
|
|
|
|
|
|
async function onPlayError(err) { |
|
|
|
if (!live.session) return |
|
|
|
|
|
|
|
// 播放器媒体面失败(TLS/CORS/HLS network):换 auth_key 没用,禁止刷 play-url
|
|
|
|
if (isFatalPlayMediaError(err) || err?.name === 'HlsError') { |
|
|
|
markPlayFatal( |
|
|
|
isFatalPlayMediaError(err) |
|
|
|
? '播放域名 HTTPS 不可用(TLS/证书异常),请检查阿里云播放域名证书' |
|
|
|
: (err?.message || '播放失败') |
|
|
|
) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if (live.playRetryCount >= PLAY_RETRY_MAX) { |
|
|
|
ui.toast(err?.message || '播放失败') |
|
|
|
live.playRetryCount = 0 |
|
|
|
markPlayFatal(err?.message || '播放失败') |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
live.playRetryCount += 1 |
|
|
|
try { |
|
|
|
await refreshPlayURL({ fromRetry: true }) |
|
|
|
} catch (e) { |
|
|
|
if (live.playRetryCount >= PLAY_RETRY_MAX) { |
|
|
|
ui.toast(e?.message || err?.message || '播放失败') |
|
|
|
live.playRetryCount = 0 |
|
|
|
} else { |
|
|
|
await onPlayError(e) |
|
|
|
if (isFatalPlayMediaError(e) || e?.name === 'HlsError' || live.playRetryCount >= PLAY_RETRY_MAX) { |
|
|
|
markPlayFatal( |
|
|
|
isFatalPlayMediaError(e) |
|
|
|
? '播放域名 HTTPS 不可用(TLS/证书异常),请检查阿里云播放域名证书' |
|
|
|
: (e?.message || err?.message || '播放失败') |
|
|
|
) |
|
|
|
return |
|
|
|
} |
|
|
|
await onPlayError(e) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|