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

Improve Telegram gif handling #6649

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/components/views/messages/MVideoBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ export default class MVideoBody extends React.PureComponent<IBodyProps, IState>

const contentUrl = this.getContentUrl();
const thumbUrl = this.getThumbUrl();
const loop = Boolean(content.info?.["fi.mau.loop"]);
const controls = !content.info?.["fi.mau.hide_controls"];
let height = null;
let width = null;
let poster = null;
Expand All @@ -252,20 +254,32 @@ export default class MVideoBody extends React.PureComponent<IBodyProps, IState>
preload = "none";
}
}
let onMouseOver;
let onMouseOut;
if (!autoplay && !controls) {
onMouseOver = event => (event.target as HTMLVideoElement).play();
onMouseOut = event => {
(event.target as HTMLVideoElement).pause();
(event.target as HTMLVideoElement).currentTime = 0;
};
}
return (
<span className="mx_MVideoBody">
<video
className="mx_MVideoBody"
ref={this.videoRef}
src={contentUrl}
title={content.body}
controls
controls={controls}
loop={loop}
preload={preload}
muted={autoplay}
autoPlay={autoplay}
height={height}
width={width}
poster={poster}
onMouseOver={onMouseOver}
onMouseOut={onMouseOut}
onPlay={this.videoOnPlay}
/>
{ this.props.tileShape && <MFileBody {...this.props} showGenericPlaceholder={false} /> }
Expand Down