提交 20e05c16 编写于 作者: Q qiang

feat(app): uni.chooseVideo compressed

上级 caa84463
......@@ -10,6 +10,10 @@ export const chooseVideo = {
params.sourceType = sourceType.length ? sourceType : SOURCE_TYPES
}
},
compressed: {
type: Boolean,
default: true
},
maxDuration: {
type: Number,
default: 60
......
......@@ -7,7 +7,8 @@ import {
} from '../../bridge'
import {
warpPlusErrorCallback
warpPlusErrorCallback,
getFileName
} from '../util'
import {
......@@ -16,26 +17,45 @@ import {
export function chooseVideo ({
sourceType,
compressed,
maxDuration,
camera
} = {}, callbackId) {
const errorCallback = warpPlusErrorCallback(callbackId, 'chooseVideo', 'cancel')
function successCallback (tempFilePath = '') {
plus.io.getVideoInfo({
filePath: tempFilePath,
success (videoInfo) {
const result = {
errMsg: 'chooseVideo:ok',
tempFilePath: tempFilePath
}
result.size = videoInfo.size
result.duration = videoInfo.duration
result.width = videoInfo.width
result.height = videoInfo.height
invoke(callbackId, result)
},
errorCallback
const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(tempFilePath)}`
const compressVideo = compressed ? plus.zip.compressVideo : function (_, callback) {
callback({ tempFilePath })
}
if (compressed) {
plus.nativeUI.showWaiting()
}
compressVideo({
src: tempFilePath,
dst
}, ({ tempFilePath }) => {
if (compressed) {
plus.nativeUI.closeWaiting()
}
plus.io.getVideoInfo({
filePath: tempFilePath,
success (videoInfo) {
const result = {
errMsg: 'chooseVideo:ok',
tempFilePath: tempFilePath
}
result.size = videoInfo.size
result.duration = videoInfo.duration
result.width = videoInfo.width
result.height = videoInfo.height
invoke(callbackId, result)
},
errorCallback
})
}, error => {
plus.nativeUI.closeWaiting()
errorCallback(error)
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册