From c9f5296e3c4067a3bb3a119b0fb448dd016e1d74 Mon Sep 17 00:00:00 2001 From: zhoulinf <2507241354@qq.com> Date: Wed, 5 Aug 2026 09:44:28 +0800 Subject: [PATCH] =?UTF-8?q?CRM=5F26-08-05#story#9126,=E8=BD=A6=E8=BE=86?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E3=80=81=E6=9C=8D=E5=8A=A1=E5=95=86=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=B3=BB=E7=BB=9F=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CameraGuide.vue | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/components/CameraGuide.vue b/src/components/CameraGuide.vue index 4fb34f30..7f09f246 100644 --- a/src/components/CameraGuide.vue +++ b/src/components/CameraGuide.vue @@ -192,6 +192,8 @@ export default { return } this.activeStream = stream + console.log('[CameraGuide] stream acquired, 来源:', this.stream ? '父组件复用' : '组件自申请', 'active:', stream.active, + 'tracks:', stream.getTracks().map(t => `${t.kind}/${t.readyState}/enabled:${t.enabled}`)) await this.$nextTick() const video = this.$refs.video if (video) { @@ -200,14 +202,37 @@ export default { video.setAttribute('playsinline', 'true') video.setAttribute('webkit-playsinline', 'true') video.srcObject = stream + const logVideoState = (tag) => { + console.log(`[CameraGuide] ${tag}:`, + 'paused:', video.paused, + 'readyState:', video.readyState, + 'currentTime:', video.currentTime, + 'videoWidth:', video.videoWidth, + 'videoHeight:', video.videoHeight, + 'streamActive:', stream.active, + 'muted:', video.muted) + } const playVideo = () => { - video.play().catch(e => console.warn('video play error:', e && (e.name || e.message || e))) + video.play() + .then(() => logVideoState('play resolved')) + .catch(e => { + console.warn('[CameraGuide] video play error:', e && (e.name || e.message || e)) + logVideoState('play rejected') + }) + } + video.onloadedmetadata = () => { + logVideoState('loadedmetadata') + playVideo() + } + video.onplaying = () => logVideoState('playing') + video.onerror = () => { + console.warn('[CameraGuide] video element error:', video.error && `${video.error.code}/${video.error.message}`) } if (video.readyState >= 1) { playVideo() - } else { - video.onloadedmetadata = playVideo } + // 2 秒后再看一次:currentTime 是否增长(判断是真在播还是黑屏死流) + setTimeout(() => logVideoState('after 2s'), 2000) } } catch (e) { // 权限拒绝或相机不可用 → 通知父组件降级为系统选择器