Naive approach, just downloading the whole chunk every time! Need to figure out caching and streaming for long-play stuff.
31 lines
No EOL
715 B
JavaScript
31 lines
No EOL
715 B
JavaScript
import util from "../../plugins/utils";
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
src: null,
|
|
downloadProgress: null
|
|
}
|
|
},
|
|
mounted() {
|
|
console.log("Mounted with event:", JSON.stringify(this.event.getContent()))
|
|
util
|
|
.getAttachment(this.$matrix.matrixClient, this.event, (progress) => {
|
|
this.downloadProgress = progress;
|
|
console.log("Progress: " + progress);
|
|
})
|
|
.then((url) => {
|
|
this.src = url;
|
|
})
|
|
.catch((err) => {
|
|
console.log("Failed to fetch attachment: ", err);
|
|
});
|
|
},
|
|
beforeDestroy() {
|
|
if (this.src) {
|
|
const objectUrl = this.src;
|
|
this.src = null;
|
|
URL.revokeObjectURL(objectUrl);
|
|
}
|
|
},
|
|
} |