feat: add auto-play functionality to inline video player on load
This commit is contained in:
parent
a752ce964a
commit
6f938243ad
|
|
@ -39,3 +39,5 @@ yarn-error.log*
|
|||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
|
||||
public/thumbnails
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.8 MiB |
|
|
@ -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]);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue