testing win editor issue

This commit is contained in:
Siddharth
2025-11-24 00:44:46 -07:00
parent dac826a5bc
commit 864902b660
3 changed files with 47 additions and 5 deletions
+13 -2
View File
@@ -59,7 +59,11 @@ export function registerIpcHandlers(
ipcMain.handle('store-recorded-video', async (_, videoData: ArrayBuffer, fileName: string) => {
try {
const videoPath = path.join(RECORDINGS_DIR, fileName)
console.log('[STORE-VIDEO] Saving to:', videoPath)
console.log('[STORE-VIDEO] RECORDINGS_DIR:', RECORDINGS_DIR)
console.log('[STORE-VIDEO] Platform:', process.platform)
await fs.writeFile(videoPath, Buffer.from(videoData))
console.log('[STORE-VIDEO] Success! File size:', Buffer.from(videoData).length, 'bytes')
return {
success: true,
@@ -67,7 +71,7 @@ export function registerIpcHandlers(
message: 'Video stored successfully'
}
} catch (error) {
console.error('Failed to store video:', error)
console.error('[STORE-VIDEO] Failed to store video:', error)
return {
success: false,
message: 'Failed to store video',
@@ -80,19 +84,26 @@ export function registerIpcHandlers(
ipcMain.handle('get-recorded-video-path', async () => {
try {
console.log('[GET-VIDEO] RECORDINGS_DIR:', RECORDINGS_DIR)
console.log('[GET-VIDEO] Platform:', process.platform)
const files = await fs.readdir(RECORDINGS_DIR)
console.log('[GET-VIDEO] All files:', files)
const videoFiles = files.filter(file => file.endsWith('.webm'))
console.log('[GET-VIDEO] Video files:', videoFiles)
if (videoFiles.length === 0) {
console.log('[GET-VIDEO] No video files found')
return { success: false, message: 'No recorded video found' }
}
const latestVideo = videoFiles.sort().reverse()[0]
const videoPath = path.join(RECORDINGS_DIR, latestVideo)
console.log('[GET-VIDEO] Latest video path:', videoPath)
console.log('[GET-VIDEO] Path separators:', videoPath.includes('\\') ? 'backslash' : 'forward slash')
return { success: true, path: videoPath }
} catch (error) {
console.error('Failed to get video path:', error)
console.error('[GET-VIDEO] Failed to get video path:', error)
return { success: false, message: 'Failed to get video path', error: String(error) }
}
})
+6 -2
View File
@@ -34,9 +34,13 @@ async function cleanupOldRecordings() {
async function ensureRecordingsDir() {
try {
await fs.mkdir(RECORDINGS_DIR, { recursive: true })
console.log('Recordings directory ready:', RECORDINGS_DIR)
console.log('='.repeat(60))
console.log('[STARTUP] Platform:', process.platform)
console.log('[STARTUP] RECORDINGS_DIR:', RECORDINGS_DIR)
console.log('[STARTUP] User Data Path:', app.getPath('userData'))
console.log('='.repeat(60))
} catch (error) {
console.error('Failed to create recordings directory:', error)
console.error('[STARTUP] Failed to create recordings directory:', error)
}
}
+28 -1
View File
@@ -47,16 +47,43 @@ export default function VideoEditor() {
const nextZoomIdRef = useRef(1);
const exporterRef = useRef<VideoExporter | null>(null);
// Helper to convert file path to proper file:// URL
const toFileUrl = (filePath: string): string => {
console.log('[VIDEO-EDITOR] Converting path to URL:', filePath);
// Normalize path separators to forward slashes
const normalized = filePath.replace(/\\/g, '/');
console.log('[VIDEO-EDITOR] Normalized path:', normalized);
// Check if it's a Windows absolute path (e.g., C:/Users/...)
if (normalized.match(/^[a-zA-Z]:/)) {
const fileUrl = `file:///${normalized}`;
console.log('[VIDEO-EDITOR] Windows file URL:', fileUrl);
return fileUrl;
}
// Unix-style absolute path
const fileUrl = `file://${normalized}`;
console.log('[VIDEO-EDITOR] Unix file URL:', fileUrl);
return fileUrl;
};
useEffect(() => {
async function loadVideo() {
try {
console.log('[VIDEO-EDITOR] Loading video...');
const result = await window.electronAPI.getRecordedVideoPath();
console.log('[VIDEO-EDITOR] getRecordedVideoPath result:', result);
if (result.success && result.path) {
setVideoPath(`file://${result.path}`);
const videoUrl = toFileUrl(result.path);
console.log('[VIDEO-EDITOR] Setting video path:', videoUrl);
setVideoPath(videoUrl);
} else {
console.error('[VIDEO-EDITOR] Failed to get video path:', result.message);
setError(result.message || 'Failed to load video');
}
} catch (err) {
console.error('[VIDEO-EDITOR] Error loading video:', err);
setError('Error loading video: ' + String(err));
} finally {
setLoading(false);