|
|
|
@ -9,6 +9,7 @@ |
|
|
|
ref="videoEl" |
|
|
|
controls |
|
|
|
autoplay |
|
|
|
muted |
|
|
|
playsinline |
|
|
|
/> |
|
|
|
<div v-else class="camera-scene"> |
|
|
|
@ -92,14 +93,29 @@ async function attachPlayer(url) { |
|
|
|
const video = videoEl.value |
|
|
|
if (!video || seq !== attachSeq) return |
|
|
|
|
|
|
|
video.muted = true |
|
|
|
video.defaultMuted = true |
|
|
|
video.setAttribute('muted', '') |
|
|
|
|
|
|
|
video.addEventListener('error', () => { |
|
|
|
if (seq !== attachSeq) return |
|
|
|
emit('error') |
|
|
|
}, { once: true }) |
|
|
|
|
|
|
|
async function tryPlay() { |
|
|
|
if (seq !== attachSeq) return |
|
|
|
try { |
|
|
|
await video.play() |
|
|
|
} catch (error) { |
|
|
|
console.warn('[live-player] autoplay blocked', error) |
|
|
|
// NotAllowedError: autoplay policy. Do not storm play-url rebuilds. |
|
|
|
if (error?.name !== 'NotAllowedError' && seq === attachSeq) emit('error') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (video.canPlayType('application/vnd.apple.mpegurl')) { |
|
|
|
video.src = url |
|
|
|
try { await video.play() } catch (_) {} |
|
|
|
await tryPlay() |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
@ -120,7 +136,8 @@ async function attachPlayer(url) { |
|
|
|
hls.attachMedia(video) |
|
|
|
hls.on(Hls.Events.MANIFEST_PARSED, () => { |
|
|
|
if (seq !== attachSeq) return |
|
|
|
video.play().catch(() => {}) |
|
|
|
video.muted = true |
|
|
|
tryPlay() |
|
|
|
}) |
|
|
|
} catch (_) { |
|
|
|
if (seq === attachSeq) emit('error') |
|
|
|
|