提交 72ea53cb 编写于 作者: X xiaoyucoding

feat: chooseVideo 读取视频信息

上级 ed1f55c1
......@@ -17,7 +17,6 @@ const _createInput = function (options) {
'width': 0,
'height': 0
})
// inputEl.style = 'position: absolute;visibility: hidden;z-index: -999;width: 0;height: 0;'
inputEl.accept = 'image/*'
if (options.count > 1) {
inputEl.multiple = 'multiple'
......
......@@ -17,7 +17,6 @@ const _createInput = function (options) {
'width': 0,
'height': 0
})
// inputEl.style = 'position: absolute;visibility: hidden;z-index: -999;width: 0;height: 0;'
inputEl.accept = 'video/*'
// 经过测试,仅能限制只通过相机拍摄,不能限制只允许从相册选择。
if (options.sourceType.length === 1 && options.sourceType[0] === 'camera') {
......@@ -43,12 +42,23 @@ export function chooseVideo ({
const file = event.target.files[0]
const filePath = fileToUrl(file)
invoke(callbackId, {
let callbackResult = {
errMsg: 'chooseVideo:ok',
tempFilePath: filePath,
size: file.size
})
size: file.size,
duration: 0,
width: 0,
height: 0
}
const video = document.createElement('video')
video.addEventListener('loadedmetadata', function () {
callbackResult.duration = video.duration || 0
callbackResult.width = video.videoWidth || 0
callbackResult.height = video.videoHeight || 0
invoke(callbackId, callbackResult)
})
video.src = filePath
// TODO 用户取消选择时,触发 fail,目前尚未找到合适的方法。
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册