Fix crashes when playing media on legacy OS

This commit is contained in:
Fedor Indutny 2021-12-11 00:27:42 +01:00 committed by GitHub
parent 2fe5ec6ab2
commit fed84be0b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 1 deletions

View file

@ -18,8 +18,10 @@ import { IMAGE_PNG, isImage, isVideo } from '../types/MIME';
import type { LocalizerType } from '../types/Util';
import type { MediaItemType, MessageAttributesType } from '../types/MediaItem';
import { formatDuration } from '../util/formatDuration';
import { showToast } from '../util/showToast';
import { useRestoreFocus } from '../hooks/useRestoreFocus';
import * as log from '../logging/log';
import { ToastUnableToLoadAttachment } from './ToastUnableToLoadAttachment';
export type PropsType = {
children?: ReactNode;
@ -453,6 +455,25 @@ export function Lightbox({
/>
);
}
} else if (isVideoTypeSupported && window.isLegacyOS()) {
const onLegacyClick = (event: React.MouseEvent<HTMLVideoElement>) => {
event.preventDefault();
event.stopPropagation();
showToast(ToastUnableToLoadAttachment);
};
content = (
<video
className="Lightbox__object"
controls={false}
key={objectURL}
loop={false}
onClick={onLegacyClick}
>
<source src={objectURL} />
</video>
);
} else if (isVideoTypeSupported) {
const shouldLoop = loop || isAttachmentGIF || isViewOnce;