mirror of
https://github.com/zadam/trilium.git
synced 2026-03-13 20:03:36 +01:00
feat(video_player): add zoom to fit button
This commit is contained in:
parent
82592ada54
commit
3fed2ba42e
@ -1051,7 +1051,9 @@
|
||||
"exit-picture-in-picture": "Exit picture-in-picture",
|
||||
"fullscreen": "Fullscreen (F)",
|
||||
"exit-fullscreen": "Exit fullscreen",
|
||||
"unsupported-format": "Video preview is not available for this file format."
|
||||
"unsupported-format": "Video preview is not available for this file format.",
|
||||
"zoom-to-fit": "Zoom to fill",
|
||||
"zoom-reset": "Reset zoom to fill"
|
||||
},
|
||||
"protected_session": {
|
||||
"enter_password_instruction": "Showing protected note requires entering your password:",
|
||||
|
||||
@ -133,6 +133,7 @@ export default function VideoPreview({ note }: { note: FNote }) {
|
||||
</div>
|
||||
<div className="right">
|
||||
<VolumeControl videoRef={videoRef} />
|
||||
<ZoomToFitButton videoRef={videoRef} />
|
||||
<PictureInPictureButton videoRef={videoRef} />
|
||||
<FullscreenButton targetRef={wrapperRef} />
|
||||
</div>
|
||||
@ -418,6 +419,27 @@ function RotateButton({ videoRef }: { videoRef: RefObject<HTMLVideoElement> }) {
|
||||
);
|
||||
}
|
||||
|
||||
function ZoomToFitButton({ videoRef }: { videoRef: RefObject<HTMLVideoElement> }) {
|
||||
const [fitted, setFitted] = useState(false);
|
||||
|
||||
const toggle = () => {
|
||||
const video = videoRef.current;
|
||||
if (!video) return;
|
||||
const next = !fitted;
|
||||
video.style.objectFit = next ? "cover" : "";
|
||||
setFitted(next);
|
||||
};
|
||||
|
||||
return (
|
||||
<ActionButton
|
||||
className={fitted ? "active" : ""}
|
||||
icon={fitted ? "bx bx-collapse" : "bx bx-expand"}
|
||||
text={fitted ? t("video.zoom-reset") : t("video.zoom-to-fit")}
|
||||
onClick={toggle}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function PictureInPictureButton({ videoRef }: { videoRef: RefObject<HTMLVideoElement> }) {
|
||||
const [active, setActive] = useState(false);
|
||||
// The standard PiP API is only supported in Chromium-based browsers.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user