filecache
This commit is contained in:
@@ -116,21 +116,12 @@
|
||||
},
|
||||
methods: {
|
||||
async init(){
|
||||
// 如果有远程 snapshotUrl,则下载到 coverCachePath
|
||||
const snapshotUrl = this.message?.videoElem?.snapshotUrl;
|
||||
const key = md5(this.message?.videoElem?.videoUrl || '');
|
||||
const coverCachePath = `${this.conversationID}/cover_${key}.jpg`;
|
||||
this.videoCachePath = `${this.conversationID}/${key}.mp4`;
|
||||
this.videoExists = await util.fileExists(this.videoCachePath);
|
||||
self.coverDownloading = true;
|
||||
util.cacheFile(snapshotUrl,coverCachePath,(e)=>{
|
||||
util.cacheFile(snapshotUrl,`${this.conversationID}`).then((fn)=>{
|
||||
self.coverDownloading = false;
|
||||
self.src = coverCachePath;
|
||||
console.log(e);
|
||||
},(e)=>{
|
||||
console.log(e);
|
||||
},(e)=>{
|
||||
console.log(e);
|
||||
self.src = fn;
|
||||
console.log(fn);
|
||||
});
|
||||
},
|
||||
clickMediaItem() {
|
||||
@@ -145,10 +136,6 @@
|
||||
},
|
||||
onOverlayClick() {
|
||||
// 点击覆盖层:如果视频已缓存则直接播放,否则开始下载
|
||||
if (this.videoExists) {
|
||||
this.playVideo("_doc/"+this.videoCachePath);
|
||||
return;
|
||||
}
|
||||
const url = this.message?.videoElem?.videoUrl || this.message?.videoElem?.videoPath;
|
||||
if (!url) {
|
||||
uni.showToast({ title: '无可下载的视频' });
|
||||
@@ -156,15 +143,12 @@
|
||||
}
|
||||
this.videoDownloading = true;
|
||||
this.videoDownloadProgress = 0;
|
||||
util.downloadFile(url, this.videoCachePath, (localPath) => {
|
||||
util.downloadFile(url, `${this.conversationID}`, (prog) => {
|
||||
//this.videoDownloadProgress = prog;
|
||||
}).then((fn) => {
|
||||
this.videoDownloading = false;
|
||||
this.videoExists = true;
|
||||
this.playVideo("_doc/"+localPath);
|
||||
}, (err) => {
|
||||
this.videoDownloading = false;
|
||||
uni.showToast({ title: '下载失败' });
|
||||
}, (prog) => {
|
||||
this.videoDownloadProgress = prog;
|
||||
this.playVideo(fn);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user