diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index 67f41c2c1e..7a11c1640b 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -1051,7 +1051,7 @@ "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": "Media preview is not available for this file format.", "zoom-to-fit": "Zoom to fill", "zoom-reset": "Reset zoom to fill" }, diff --git a/apps/client/src/widgets/type_widgets/file/Audio.tsx b/apps/client/src/widgets/type_widgets/file/Audio.tsx index 81f343405b..95e68aa2c2 100644 --- a/apps/client/src/widgets/type_widgets/file/Audio.tsx +++ b/apps/client/src/widgets/type_widgets/file/Audio.tsx @@ -1,14 +1,16 @@ -import { MutableRef, useCallback, useRef, useState } from "preact/hooks"; +import { MutableRef, useCallback, useEffect, useRef, useState } from "preact/hooks"; import FNote from "../../../entities/fnote"; import { t } from "../../../services/i18n"; import { getUrlForDownload } from "../../../services/open"; +import NoItems from "../../react/NoItems"; import { LoopButton, PlaybackSpeed, PlayPauseButton, SeekBar, SkipButton, VolumeControl } from "./MediaPlayer"; export default function AudioPreview({ note }: { note: FNote }) { - const [playing, setPlaying] = useState(false); const wrapperRef = useRef(null); const audioRef = useRef(null); + const [playing, setPlaying] = useState(false); + const [error, setError] = useState(false); const togglePlayback = useCallback(() => { const audio = audioRef.current; if (!audio) return; @@ -20,6 +22,13 @@ export default function AudioPreview({ note }: { note: FNote }) { }, []); const onKeyDown = useKeyboardShortcuts(audioRef, wrapperRef, togglePlayback); + useEffect(() => setError(false), [note.noteId]); + const onError = useCallback(() => setError(true), []); + + if (error) { + return ; + } + return (