feat: add auto-play functionality to inline video player on load

This commit is contained in:
tigeren 2025-08-26 02:18:18 +00:00
parent a752ce964a
commit 6f938243ad
4 changed files with 14 additions and 0 deletions

2
.gitignore vendored
View File

@ -39,3 +39,5 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
public/thumbnails

BIN
media.db

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 MiB

View File

@ -39,6 +39,18 @@ export default function InlineVideoPlayer({ video, isOpen, onClose, scrollPositi
if (isOpen && videoRef.current) {
videoRef.current.src = `/api/stream/${video.id}`;
videoRef.current.load();
// Auto-play when video is loaded
videoRef.current.addEventListener('loadeddata', () => {
if (videoRef.current) {
videoRef.current.play().then(() => {
setIsPlaying(true);
}).catch((error) => {
console.log('Auto-play prevented by browser:', error);
// Auto-play might be blocked by browser, that's okay
});
}
});
}
}, [isOpen, video.id]);