Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit c8d3b51

Browse files
authored
fix quicktime video thumbnailing (#8108)
when reading quicktime files for thumbnailing and/or display, clobber the mimetype from `video/quicktime` to be `video/mp4` so browsers don't choke on it.
1 parent a80e55d commit c8d3b51

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/ContentMessages.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,14 @@ function loadVideoElement(videoFile): Promise<HTMLVideoElement> {
292292
reject(e);
293293
};
294294

295-
video.src = ev.target.result as string;
295+
let dataUrl = ev.target.result as string;
296+
// Chrome chokes on quicktime but likes mp4, and `file.type` is
297+
// read only, so do this horrible hack to unbreak quicktime
298+
if (dataUrl.startsWith("data:video/quicktime;")) {
299+
dataUrl = dataUrl.replace("data:video/quicktime;", "data:video/mp4;");
300+
}
301+
302+
video.src = dataUrl;
296303
video.load();
297304
video.play();
298305
};

src/components/views/messages/MVideoBody.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,21 @@ export default class MVideoBody extends React.PureComponent<IBodyProps, IState>
190190
} else {
191191
logger.log("NOT preloading video");
192192
const content = this.props.mxEvent.getContent<IMediaEventContent>();
193+
194+
let mimetype = content?.info?.mimetype;
195+
196+
// clobber quicktime muxed files to be considered MP4 so browsers
197+
// are willing to play them
198+
if (mimetype == "video/quicktime") {
199+
mimetype = "video/mp4";
200+
}
201+
193202
this.setState({
194203
// For Chrome and Electron, we need to set some non-empty `src` to
195204
// enable the play button. Firefox does not seem to care either
196205
// way, so it's fine to do for all browsers.
197-
decryptedUrl: `data:${content?.info?.mimetype},`,
198-
decryptedThumbnailUrl: thumbnailUrl || `data:${content?.info?.mimetype},`,
206+
decryptedUrl: `data:${mimetype},`,
207+
decryptedThumbnailUrl: thumbnailUrl || `data:${mimetype},`,
199208
decryptedBlob: null,
200209
});
201210
}

0 commit comments

Comments
 (0)