From 948249bb3de9838d11a8a9fceefe85ea10826b28 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 10 Mar 2021 13:39:34 +0100 Subject: [PATCH] better error reporting for unsupported codecs when uploading --- src/domain/session/room/RoomViewModel.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/domain/session/room/RoomViewModel.js b/src/domain/session/room/RoomViewModel.js index 6a83446a..a6d5454a 100644 --- a/src/domain/session/room/RoomViewModel.js +++ b/src/domain/session/room/RoomViewModel.js @@ -188,12 +188,13 @@ export class RoomViewModel extends ViewModel { } async _pickAndSendVideo() { + let file; try { if (!this.platform.hasReadPixelPermission()) { alert("Please allow canvas image data access, so we can scale your images down."); return; } - const file = await this.platform.openFile("video/*"); + file = await this.platform.openFile("video/*"); if (!file) { return; } @@ -218,7 +219,11 @@ export class RoomViewModel extends ViewModel { this._room.createAttachment(thumbnail.blob, file.name); await this._room.sendEvent("m.room.message", content, attachments); } catch (err) { - this._sendError = 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.emitChange("error"); console.error(err.stack); }