Skip to content

Commit

Permalink
fix(h5): 修复部分浏览器下选择视频后无响应的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyucoding committed May 9, 2019
1 parent f41e15a commit bc23156
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/platforms/h5/service/api/media/choose-video.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ export function chooseVideo ({
}

const video = document.createElement('video')
video.addEventListener('loadedmetadata', function () {
callbackResult.duration = video.duration || 0
callbackResult.width = video.videoWidth || 0
callbackResult.height = video.videoHeight || 0
if (video.onloadedmetadata) {
// 尝试获取视频的宽高信息
video.onloadedmetadata = function () {
callbackResult.duration = video.duration || 0
callbackResult.width = video.videoWidth || 0
callbackResult.height = video.videoHeight || 0
invoke(callbackId, callbackResult)
}
video.src = filePath
} else {
invoke(callbackId, callbackResult)
})
video.src = filePath
}
// TODO 用户取消选择时,触发 fail,目前尚未找到合适的方法。
})

Expand Down

0 comments on commit bc23156

Please sign in to comment.