-
- {#if sourceLoadError}
-
- {sourceLoadError}
-
- {/if}
+
+
+
+
+ {#if sourceLoadError}
+
+ {sourceLoadError}
+
+ {/if}
+
+
diff --git a/lightly_studio_view/src/lib/components/VideoPlayer/VideoPlayer.test.ts b/lightly_studio_view/src/lib/components/VideoPlayer/VideoPlayer.test.ts
index 43f741366..f809fc1dc 100644
--- a/lightly_studio_view/src/lib/components/VideoPlayer/VideoPlayer.test.ts
+++ b/lightly_studio_view/src/lib/components/VideoPlayer/VideoPlayer.test.ts
@@ -21,18 +21,18 @@ describe('VideoPlayer', () => {
expect(video?.getAttribute('preload')).toBe('metadata');
});
- it('should not show controls by default', () => {
+ it('should not show native controls by default', () => {
const { container } = render(VideoPlayer, { props: { src: 'test-video.mp4' } });
const video = container.querySelector('video');
expect(video?.hasAttribute('controls')).toBe(false);
});
- it('should show controls when controls prop is true', () => {
+ it('should force native controls off even when videoProps requests them', () => {
const { container } = render(VideoPlayer, {
props: { src: 'test-video.mp4', videoProps: { controls: true } }
});
const video = container.querySelector('video');
- expect(video?.hasAttribute('controls')).toBe(true);
+ expect(video?.hasAttribute('controls')).toBe(false);
});
it('should apply custom className via videoProps', () => {
@@ -117,4 +117,12 @@ describe('VideoPlayer', () => {
const video = container.querySelector('video');
expect(video?.getAttribute('preload')).toBe('auto');
});
+
+ it('should render the custom control bar', () => {
+ const { getByRole, getByLabelText } = render(VideoPlayer, {
+ props: { src: 'test-video.mp4' }
+ });
+ expect(getByRole('slider')).toBeTruthy();
+ expect(getByLabelText('Play')).toBeTruthy();
+ });
});
diff --git a/lightly_studio_view/src/lib/components/VideoPlayer/useVideoPlayback.svelte.ts b/lightly_studio_view/src/lib/components/VideoPlayer/useVideoPlayback.svelte.ts
index 723b5dabc..504e08748 100644
--- a/lightly_studio_view/src/lib/components/VideoPlayer/useVideoPlayback.svelte.ts
+++ b/lightly_studio_view/src/lib/components/VideoPlayer/useVideoPlayback.svelte.ts
@@ -94,10 +94,7 @@ export function useVideoPlayback({
// Keep the fullscreen flag in sync however it's entered/left.
$effect(() => {
if (typeof document === 'undefined') return;
- const syncFullscreen = () => {
- const regionEl = getRegionEl();
- isFullscreen = regionEl != null && document.fullscreenElement === regionEl;
- };
+ const syncFullscreen = () => (isFullscreen = document.fullscreenElement === getRegionEl());
document.addEventListener('fullscreenchange', syncFullscreen);
return () => document.removeEventListener('fullscreenchange', syncFullscreen);
});
@@ -128,11 +125,10 @@ export function useVideoPlayback({
function toggleFullscreen() {
if (typeof document === 'undefined') return;
const regionEl = getRegionEl();
- if (!regionEl) return;
if (document.fullscreenElement === regionEl) {
void document.exitFullscreen();
} else {
- void regionEl.requestFullscreen();
+ void regionEl?.requestFullscreen();
}
}