poster image fix

This commit is contained in:
Yiannis Christodoulou 2025-10-19 14:19:13 +03:00
parent 0a68060700
commit 95cb6904ce
10 changed files with 110 additions and 86 deletions

View File

@ -42,9 +42,10 @@ const IOSVideoPlayer = ({ videoRef, currentTime, duration }: IOSVideoPlayerProps
// Check if the media is an audio file and set poster image
const isAudioFile = url.match(/\.(mp3|wav|ogg|m4a|aac|flac)$/i) !== null;
// Get posterUrl from MEDIA_DATA, or use audio-poster.jpg as fallback for audio files when posterUrl is empty
// 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) || '';
setPosterImage(mediaPosterUrl || (isAudioFile ? '/audio-poster.jpg' : undefined));
const isValidPoster = mediaPosterUrl && mediaPosterUrl !== 'None' && mediaPosterUrl.trim() !== '';
setPosterImage(isValidPoster ? mediaPosterUrl : (isAudioFile ? '/audio-poster.jpg' : undefined));
}, [videoRef]);
// Function to jump 15 seconds backward

View File

@ -41,9 +41,10 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({
// Check if the media is an audio file
const isAudioFile = sampleVideoUrl.match(/\.(mp3|wav|ogg|m4a|aac|flac)$/i) !== null;
// Get posterUrl from MEDIA_DATA, or use audio-poster.jpg as fallback for audio files when posterUrl is empty
// 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 posterImage = mediaPosterUrl || (isAudioFile ? '/audio-poster.jpg' : undefined);
const isValidPoster = mediaPosterUrl && mediaPosterUrl !== 'None' && mediaPosterUrl.trim() !== '';
const posterImage = isValidPoster ? mediaPosterUrl : (isAudioFile ? '/audio-poster.jpg' : undefined);
// Detect iOS device and Safari browser
useEffect(() => {

View File

@ -2,12 +2,33 @@ import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path, { dirname } from 'path';
import { fileURLToPath } from 'url';
import { copyFileSync, mkdirSync } from 'fs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Plugin to copy audio-poster.jpg to build output
const copyAudioPoster = () => {
return {
name: 'copy-audio-poster',
closeBundle() {
const outDir = path.resolve(__dirname, '../../../static/video_editor');
const sourceFile = path.resolve(__dirname, 'client/public/audio-poster.jpg');
const destFile = path.resolve(outDir, 'audio-poster.jpg');
try {
mkdirSync(outDir, { recursive: true });
copyFileSync(sourceFile, destFile);
console.log('✓ Copied audio-poster.jpg to build output');
} catch (error) {
console.error('Error copying audio-poster.jpg:', error);
}
},
};
};
export default defineConfig({
plugins: [react()],
plugins: [react(), copyAudioPoster()],
resolve: {
alias: {
'@': path.resolve(__dirname, 'client', 'src'),

View File

@ -42,9 +42,10 @@ const IOSVideoPlayer = ({ videoRef, currentTime, duration }: IOSVideoPlayerProps
// Check if the media is an audio file and set poster image
const isAudioFile = url.match(/\.(mp3|wav|ogg|m4a|aac|flac)$/i) !== null;
// Get posterUrl from MEDIA_DATA, or use audio-poster.jpg as fallback for audio files when posterUrl is empty
// 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) || '';
setPosterImage(mediaPosterUrl || (isAudioFile ? '/audio-poster.jpg' : undefined));
const isValidPoster = mediaPosterUrl && mediaPosterUrl !== 'None' && mediaPosterUrl.trim() !== '';
setPosterImage(isValidPoster ? mediaPosterUrl : (isAudioFile ? '/audio-poster.jpg' : undefined));
}, [videoRef]);
// Function to jump 15 seconds backward

View File

@ -1132,7 +1132,6 @@ const TimelineControls = ({
endTime: parseTimeString(seg.endTime),
thumbnail: '',
}));
console.log('convertedSegments', convertedSegments);
// Dispatch event to update segments
const updateEvent = new CustomEvent('update-segments', {

View File

@ -41,9 +41,10 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({
// Check if the media is an audio file
const isAudioFile = sampleVideoUrl.match(/\.(mp3|wav|ogg|m4a|aac|flac)$/i) !== null;
// Get posterUrl from MEDIA_DATA, or use audio-poster.jpg as fallback for audio files when posterUrl is empty
// 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 posterImage = mediaPosterUrl || (isAudioFile ? '/audio-poster.jpg' : undefined);
const isValidPoster = mediaPosterUrl && mediaPosterUrl !== 'None' && mediaPosterUrl.trim() !== '';
const posterImage = isValidPoster ? mediaPosterUrl : (isAudioFile ? '/audio-poster.jpg' : undefined);
// Detect iOS device
useEffect(() => {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long