From e5160b7af0bd16971928fa204655669e8cfa980c Mon Sep 17 00:00:00 2001 From: qiang Date: Mon, 6 Jan 2020 16:16:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E5=86=85=E7=BD=AE=E6=B5=8F=E8=A7=88=E5=99=A8uni.chooseVideo?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E4=B8=8D=E8=A7=A6=E5=8F=91=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../h5/service/api/media/choose-video.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/platforms/h5/service/api/media/choose-video.js b/src/platforms/h5/service/api/media/choose-video.js index 6d473ebcd..65258be59 100644 --- a/src/platforms/h5/service/api/media/choose-video.js +++ b/src/platforms/h5/service/api/media/choose-video.js @@ -50,7 +50,7 @@ export function chooseVideo ({ size: file.size, duration: 0, width: 0, - height: 0, + height: 0, name: file.name } @@ -58,11 +58,20 @@ export function chooseVideo ({ if (video.onloadedmetadata !== undefined) { // 尝试获取视频的宽高信息 video.onloadedmetadata = function () { - callbackResult.duration = video.duration || 0 - callbackResult.width = video.videoWidth || 0 - callbackResult.height = video.videoHeight || 0 - invoke(callbackId, callbackResult) + invoke(callbackId, Object.assign({}, callbackResult, { + duration: video.duration || 0, + width: video.videoWidth || 0, + height: video.videoHeight || 0 + })) } + // 部分浏览器(如微信内置浏览器)未播放无法触发loadedmetadata事件 + setTimeout(() => { + invoke(callbackId, Object.assign({}, callbackResult, { + duration: 0, + width: 0, + height: 0 + })) + }, 300) video.src = filePath } else { invoke(callbackId, callbackResult) -- GitLab