关键代码:
fuckWxMiniprogram(e) {
const self = this;
wx.chooseMedia({
mediaType: ["video", "image"],
sourceType: ["album"],
sizeType: ["original"],
success: async function(res) {
console.log("try to load file");
self.doReadFileByWechat(res.tempFiles)
},
fail: res => {
wx.hideLoading();
}
})
},
doReadFileByWechat(files) {
let n = 0;
const bufferSize = 1048576;
const fs = wx.getFileSystemManager();
const fd = fs.openSync({
filePath: files[0].tempFilePath,
flag: "r"
});
const stats = fs.fstatSync({ fd: fd });
while ( n < stats.size ) {
let ab = new ArrayBuffer(bufferSize);
const data = fs.readSync({
fd: fd,
arrayBuffer: ab,
length: bufferSize,
complete: res => {
console.log(res)
}
});
n += data.bytesRead;
}
}
开发者工具Window端这个API没问题,但是读取一个2G的视频文件直接内存泄漏
无力吐槽
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
顺便说一下 但凡你认真点看问题都不至于能问出这个话