diff --git a/apps/client/src/widgets/type_widgets/file/Audio.tsx b/apps/client/src/widgets/type_widgets/file/Audio.tsx index 99de10caf2..ffd83b5e51 100644 --- a/apps/client/src/widgets/type_widgets/file/Audio.tsx +++ b/apps/client/src/widgets/type_widgets/file/Audio.tsx @@ -1,8 +1,9 @@ import { useRef, useState } from "preact/hooks"; import FNote from "../../../entities/fnote"; +import { t } from "../../../services/i18n"; import { getUrlForDownload } from "../../../services/open"; -import { PlayPauseButton, SeekBar, VolumeControl } from "./MediaPlayer"; +import { PlayPauseButton, SeekBar, SkipButton, VolumeControl } from "./MediaPlayer"; export default function AudioPreview({ note }: { note: FNote }) { const [playing, setPlaying] = useState(false); @@ -24,7 +25,9 @@ export default function AudioPreview({ note }: { note: FNote }) {
+ +
diff --git a/apps/client/src/widgets/type_widgets/file/MediaPlayer.tsx b/apps/client/src/widgets/type_widgets/file/MediaPlayer.tsx index 376984ca5c..6049a53ee6 100644 --- a/apps/client/src/widgets/type_widgets/file/MediaPlayer.tsx +++ b/apps/client/src/widgets/type_widgets/file/MediaPlayer.tsx @@ -134,3 +134,15 @@ export function VolumeControl({ mediaRef }: { mediaRef: RefObject ); } + +export function SkipButton({ mediaRef, seconds, icon, text }: { mediaRef: RefObject, seconds: number, icon: string, text: string }) { + const skip = () => { + const media = mediaRef.current; + if (!media) return; + media.currentTime = Math.max(0, Math.min(media.duration, media.currentTime + seconds)); + }; + + return ( + + ); +} diff --git a/apps/client/src/widgets/type_widgets/file/Video.tsx b/apps/client/src/widgets/type_widgets/file/Video.tsx index f6a22e3d4c..c22725f70e 100644 --- a/apps/client/src/widgets/type_widgets/file/Video.tsx +++ b/apps/client/src/widgets/type_widgets/file/Video.tsx @@ -10,7 +10,7 @@ import ActionButton from "../../react/ActionButton"; import Dropdown from "../../react/Dropdown"; import Icon from "../../react/Icon"; import NoItems from "../../react/NoItems"; -import { PlayPauseButton, SeekBar, VolumeControl } from "./MediaPlayer"; +import { PlayPauseButton, SeekBar, SkipButton, VolumeControl } from "./MediaPlayer"; const AUTO_HIDE_DELAY = 3000; @@ -122,9 +122,9 @@ export default function VideoPreview({ note }: { note: FNote }) {
- + - +
@@ -169,18 +169,6 @@ function useAutoHideControls(videoRef: RefObject, playing: boo return { visible, onMouseMove, flash: onMouseMove }; } -function SkipButton({ videoRef, seconds, icon, text }: { videoRef: RefObject, seconds: number, icon: string, text: string }) { - const skip = () => { - const video = videoRef.current; - if (!video) return; - video.currentTime = Math.max(0, Math.min(video.duration, video.currentTime + seconds)); - }; - - return ( - - ); -} - const PLAYBACK_SPEEDS = [0.5, 1, 1.25, 1.5, 2]; function PlaybackSpeed({ videoRef }: { videoRef: RefObject }) {