demo地址: https://github.com/cyanyiyi/5-code-err-demo.git
真机调试 iphone手机
我用chooseImg配合resolveLocalFileSystemURL,可以实现调用摄像头拍摄照片,然后转成base64传送给后台,但是当用chooseVideo拍摄视频然后用resolveLocalFileSystemURL处理的时候会报 编码错误
http://ask.dcloud.net.cn/question/8445 有提到要在视频path前加file:// 但是我加了之后报错 由 编码错误 变成 不允许读
e_shootFace() {
const that = this;
uni.chooseVideo({
count: 1,
sourceType: ['album', 'camera'],
success: function (res) {
//#ifdef APP-PLUS
plus.nativeUI.alert(JSON.stringify(res));
const tempFilePath = res.tempFilePath;
uni.saveVideoToPhotosAlbum({
filePath: tempFilePath,
success: function () {
plus.nativeUI.alert('save success');
}
});
plus.nativeUI.alert(tempFilePath);
plus.io.resolveLocalFileSystemURL(tempFilePath, function (entry) {
entry.file(function (file) {
const fileReader = new plus.io.FileReader();
fileReader.readAsDataURL(file, 'utf-8');
fileReader.onloadend = function (evt) {
// console.log(evt.target.fileName);
plus.nativeUI.alert('onloadend');
plus.nativeUI.alert(evt.target.fileName);
request.post({
url: '/face/faceRawVideo/uploadValidateVideo',
data: {
data: {
fileName: evt.target.fileName,
base64: evt.target.result
}
}
}).then(d => {
plus.nativeUI.alert("d" + JSON.stringify(d));
that.faceFlag = true;
that.faceVideoSrc = tempFilePath;
uni.hideLoading();
}, d => {
plus.nativeUI.alert("err" + JSON.stringify(d));
that.faceFlag = false;
uni.hideLoading();
})
}
});
}, function (e) {
plus.nativeUI.alert("Resolve file URL failed: " + e.message);
that.faceFlag = false;
uni.hideLoading();
});
//#endif
}
});
},
7***@qq.com
万分感谢 谢谢谢谢
2019-06-04 22:03