better error reporting for unsupported codecs when uploading

This commit is contained in:
Bruno Windels 2021-03-10 13:39:34 +01:00
parent c8265b2358
commit 948249bb3d

View file

@ -188,12 +188,13 @@ export class RoomViewModel extends ViewModel {
} }
async _pickAndSendVideo() { async _pickAndSendVideo() {
let file;
try { try {
if (!this.platform.hasReadPixelPermission()) { if (!this.platform.hasReadPixelPermission()) {
alert("Please allow canvas image data access, so we can scale your images down."); alert("Please allow canvas image data access, so we can scale your images down.");
return; return;
} }
const file = await this.platform.openFile("video/*"); file = await this.platform.openFile("video/*");
if (!file) { if (!file) {
return; return;
} }
@ -218,7 +219,11 @@ export class RoomViewModel extends ViewModel {
this._room.createAttachment(thumbnail.blob, file.name); this._room.createAttachment(thumbnail.blob, file.name);
await this._room.sendEvent("m.room.message", content, attachments); await this._room.sendEvent("m.room.message", content, attachments);
} catch (err) { } catch (err) {
if (err instanceof window.MediaError && err.code === 4) {
this._sendError = new Error(`this browser does not support videos of type ${file?.blob.mimeType}.`);
} else {
this._sendError = err; this._sendError = err;
}
this.emitChange("error"); this.emitChange("error");
console.error(err.stack); console.error(err.stack);
} }