FIX: Enhance video playback and implement smart aspect ratio window sizing
- Replace ReactPlayer with native HTML5 video for better MP4 support - Add proper MIME type mapping for all video formats (mp4, webm, mkv, avi, mov, wmv, flv) - Implement smart window sizing based on media dimensions - Auto-adjust window size to match image/video aspect ratio with constraints - Add media dimension detection for images (naturalWidth/Height) and videos (videoWidth/Height) - Center windows automatically when resizing for media content - Apply intelligent scaling with max viewport limits (90% width, 80% height) - Preserve minimum window sizes and add padding for UI elements - Enhanced error handling and debug logging for video playback 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -71,6 +71,7 @@ export function FileWindow({
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [isEditable, setIsEditable] = useState(false);
|
||||
const [pendingContent, setPendingContent] = useState<string>("");
|
||||
const [mediaDimensions, setMediaDimensions] = useState<{ width: number; height: number } | undefined>();
|
||||
const autoSaveTimerRef = useRef<NodeJS.Timeout | null>(null);
|
||||
|
||||
const currentWindow = windows.find((w) => w.id === windowId);
|
||||
@@ -365,6 +366,12 @@ export function FileWindow({
|
||||
focusWindow(windowId);
|
||||
};
|
||||
|
||||
// Handle media dimensions change
|
||||
const handleMediaDimensionsChange = (dimensions: { width: number; height: number }) => {
|
||||
console.log('Media dimensions received:', dimensions);
|
||||
setMediaDimensions(dimensions);
|
||||
};
|
||||
|
||||
if (!currentWindow) {
|
||||
return null;
|
||||
}
|
||||
@@ -383,6 +390,7 @@ export function FileWindow({
|
||||
onFocus={handleFocus}
|
||||
isMaximized={currentWindow.isMaximized}
|
||||
zIndex={currentWindow.zIndex}
|
||||
targetSize={mediaDimensions}
|
||||
>
|
||||
<FileViewer
|
||||
file={file}
|
||||
@@ -393,6 +401,7 @@ export function FileWindow({
|
||||
onContentChange={handleContentChange}
|
||||
onSave={(newContent) => handleSave(newContent)}
|
||||
onDownload={handleDownload}
|
||||
onMediaDimensionsChange={handleMediaDimensionsChange}
|
||||
/>
|
||||
</DraggableWindow>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user