Initial implementation of "audio mode"

This commit is contained in:
N Pex 2023-01-30 08:36:02 +00:00
parent d5942fdb8e
commit 09173a65f1
14 changed files with 944 additions and 410 deletions

View file

@ -7,25 +7,41 @@ export default {
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);
watch: {
event: {
immediate: false,
handler(value, ignoredOldValue) {
this.loadAttachmentSource(value);
}
}
},
mounted() {
this.loadAttachmentSource(this.event);
},
beforeDestroy() {
this.loadAttachmentSource(null); // Release
},
methods: {
loadAttachmentSource(event) {
if (this.src) {
const objectUrl = this.src;
this.src = null;
URL.revokeObjectURL(objectUrl);
}
if (event) {
util
.getAttachment(this.$matrix.matrixClient, event, (progress) => {
this.downloadProgress = progress;
console.log("Progress: " + progress);
})
.then((url) => {
this.src = url;
})
.catch((err) => {
console.log("Failed to fetch attachment: ", err);
});
}
}
}
}