From e6f395c6439712edb22eaaffb0b76f42ecac6772 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 18 Jul 2022 17:33:11 +0100 Subject: [PATCH 1/2] Add support to play .mov files (#672) * update allowed mimetypes * fix .mov files failing to play in Chromium * add check for before passing to FileReader * add missing semi-colon --- src/app/molecules/media/Media.jsx | 10 +++++++++- src/client/state/RoomsInput.js | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/app/molecules/media/Media.jsx b/src/app/molecules/media/Media.jsx index 6fc38517..341dcb03 100644 --- a/src/app/molecules/media/Media.jsx +++ b/src/app/molecules/media/Media.jsx @@ -12,15 +12,19 @@ import DownloadSVG from '../../../../public/res/ic/outlined/download.svg'; import ExternalSVG from '../../../../public/res/ic/outlined/external.svg'; import PlaySVG from '../../../../public/res/ic/outlined/play.svg'; -// https://github.com/matrix-org/matrix-react-sdk/blob/a9e28db33058d1893d964ec96cd247ecc3d92fc3/src/utils/blobs.ts#L73 +// https://github.com/matrix-org/matrix-react-sdk/blob/cd15e08fc285da42134817cce50de8011809cd53/src/utils/blobs.ts#L73 const ALLOWED_BLOB_MIMETYPES = [ 'image/jpeg', 'image/gif', 'image/png', + 'image/apng', + 'image/webp', + 'image/avif', 'video/mp4', 'video/webm', 'video/ogg', + 'video/quicktime', 'audio/mp4', 'audio/webm', @@ -38,6 +42,10 @@ function getBlobSafeMimeType(mimetype) { if (!ALLOWED_BLOB_MIMETYPES.includes(mimetype)) { return 'application/octet-stream'; } + // Required for Chromium browsers + if (mimetype === 'video/quicktime') { + return 'video/mp4'; + } return mimetype; } diff --git a/src/client/state/RoomsInput.js b/src/client/state/RoomsInput.js index 4bbd3d88..882c7bc0 100644 --- a/src/client/state/RoomsInput.js +++ b/src/client/state/RoomsInput.js @@ -46,7 +46,12 @@ function loadVideo(videoFile) { reader.onerror = (e) => { reject(e); }; - reader.readAsDataURL(videoFile); + if (videoFile.type === 'video/quicktime') { + const quicktimeVideoFile = new File([videoFile], videoFile.name, { type: 'video/mp4' }); + reader.readAsDataURL(quicktimeVideoFile); + } else { + reader.readAsDataURL(videoFile); + } }); } function getVideoThumbnail(video, width, height, mimeType) { From 1211ca277b7fe1fde956176729ca1a349b317556 Mon Sep 17 00:00:00 2001 From: Dean Bassett Date: Mon, 18 Jul 2022 09:36:51 -0700 Subject: [PATCH 2/2] Support mark as read by ESC while in room input (#669) fixes #cinnyapp/cinny/668 --- src/client/event/hotkeys.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/client/event/hotkeys.js b/src/client/event/hotkeys.js index c1b2af1d..22170653 100644 --- a/src/client/event/hotkeys.js +++ b/src/client/event/hotkeys.js @@ -51,9 +51,6 @@ function listenKeyboard(event) { if (!event.ctrlKey && !event.altKey && !event.metaKey) { if (navigation.isRawModalVisible) return; - if (['input', 'textarea'].includes(document.activeElement.tagName.toLowerCase())) { - return; - } if (event.code === 'Escape') { if (navigation.isRoomSettings) { @@ -66,6 +63,10 @@ function listenKeyboard(event) { } } + if (['input', 'textarea'].includes(document.activeElement.tagName.toLowerCase())) { + return; + } + // focus the text field on most keypresses if (shouldFocusMessageField(event.code)) { // press any key to focus and type in message field