From 9a8a34317d73316c77e9cad8b3fa1792a1300694 Mon Sep 17 00:00:00 2001 From: Yiannis Christodoulou Date: Sun, 9 Nov 2025 21:54:18 +0200 Subject: [PATCH] Fix audio poster display for Safari in video players (144) Adds persistent background poster images for audio files in both VideoPlayer and IOSVideoPlayer components to address Safari rendering issues. Updates CSS and component logic to ensure poster images remain visible for audio files, improving user experience and visual consistency. --- .../client/src/components/IOSVideoPlayer.tsx | 50 ++++++++++++------- .../client/src/components/VideoPlayer.tsx | 10 ++++ .../client/src/styles/IOSVideoPlayer.css | 30 ++++++++++- .../client/src/styles/VideoPlayer.css | 23 +++++++++ .../client/src/components/IOSVideoPlayer.tsx | 50 ++++++++++++------- .../client/src/components/VideoPlayer.tsx | 10 ++++ .../client/src/styles/IOSVideoPlayer.css | 30 ++++++++++- .../client/src/styles/VideoPlayer.css | 23 +++++++++ 8 files changed, 188 insertions(+), 38 deletions(-) diff --git a/frontend-tools/chapters-editor/client/src/components/IOSVideoPlayer.tsx b/frontend-tools/chapters-editor/client/src/components/IOSVideoPlayer.tsx index e5bd3f48..b67093e0 100644 --- a/frontend-tools/chapters-editor/client/src/components/IOSVideoPlayer.tsx +++ b/frontend-tools/chapters-editor/client/src/components/IOSVideoPlayer.tsx @@ -13,6 +13,7 @@ const IOSVideoPlayer = ({ videoRef, currentTime, duration }: IOSVideoPlayerProps const [videoUrl, setVideoUrl] = useState(''); const [iosVideoRef, setIosVideoRef] = useState(null); const [posterImage, setPosterImage] = useState(undefined); + const [isAudioFile, setIsAudioFile] = useState(false); // Refs for hold-to-continue functionality const incrementIntervalRef = useRef(null); @@ -41,12 +42,13 @@ const IOSVideoPlayer = ({ videoRef, currentTime, duration }: IOSVideoPlayerProps setVideoUrl(url); // Check if the media is an audio file and set poster image - const isAudioFile = url.match(/\.(mp3|wav|ogg|m4a|aac|flac)$/i) !== null; + const audioFile = url.match(/\.(mp3|wav|ogg|m4a|aac|flac)$/i) !== null; + setIsAudioFile(audioFile); // Get posterUrl from MEDIA_DATA, or use audio-poster.jpg as fallback for audio files when posterUrl is empty, null, or "None" const mediaPosterUrl = (typeof window !== 'undefined' && (window as any).MEDIA_DATA?.posterUrl) || ''; const isValidPoster = mediaPosterUrl && mediaPosterUrl !== 'None' && mediaPosterUrl.trim() !== ''; - setPosterImage(isValidPoster ? mediaPosterUrl : (isAudioFile ? AUDIO_POSTER_URL : undefined)); + setPosterImage(isValidPoster ? mediaPosterUrl : (audioFile ? AUDIO_POSTER_URL : undefined)); }, [videoRef]); // Function to jump 15 seconds backward @@ -128,22 +130,34 @@ const IOSVideoPlayer = ({ videoRef, currentTime, duration }: IOSVideoPlayerProps - {/* iOS-optimized Video Element with Native Controls */} - + {/* Video container with persistent background for audio files */} +
+ {/* Persistent background image for audio files (Safari fix) */} + {isAudioFile && posterImage && ( + {/* iOS Video Skip Controls */}
diff --git a/frontend-tools/chapters-editor/client/src/components/VideoPlayer.tsx b/frontend-tools/chapters-editor/client/src/components/VideoPlayer.tsx index 1fc874d2..75dc6515 100644 --- a/frontend-tools/chapters-editor/client/src/components/VideoPlayer.tsx +++ b/frontend-tools/chapters-editor/client/src/components/VideoPlayer.tsx @@ -353,8 +353,18 @@ const VideoPlayer: React.FC = ({ return (
+ {/* Persistent background image for audio files (Safari fix) */} + {isAudioFile && posterImage && ( + - {/* iOS-optimized Video Element with Native Controls */} - + {/* Video container with persistent background for audio files */} +
+ {/* Persistent background image for audio files (Safari fix) */} + {isAudioFile && posterImage && ( + {/* iOS Video Skip Controls */}
diff --git a/frontend-tools/video-editor/client/src/components/VideoPlayer.tsx b/frontend-tools/video-editor/client/src/components/VideoPlayer.tsx index 36fcacfe..1c238ea7 100644 --- a/frontend-tools/video-editor/client/src/components/VideoPlayer.tsx +++ b/frontend-tools/video-editor/client/src/components/VideoPlayer.tsx @@ -353,8 +353,18 @@ const VideoPlayer: React.FC = ({ return (
+ {/* Persistent background image for audio files (Safari fix) */} + {isAudioFile && posterImage && ( +