diff --git a/materialious/src/lib/Player.svelte b/materialious/src/lib/Player.svelte index d1faa62f..12f354ce 100644 --- a/materialious/src/lib/Player.svelte +++ b/materialious/src/lib/Player.svelte @@ -21,7 +21,6 @@ import { getDynamicTheme } from './theme'; export let data: { video: VideoPlay; content: PhasedDescription; playlistId: string | null }; - export let currentTime: number = 0; export let audioMode = false; export let player: MediaPlayerElement; export let isSyncing: boolean = false; @@ -38,13 +37,6 @@ const proxyVideos = get(playerProxyVideos); onMount(async () => { - try { - const defaultVolume = localStorage.getItem('volume'); - if (defaultVolume) { - player.volume = Number(defaultVolume); - } - } catch {} - if (!data.video.hlsUrl) { if (data.video.captions) { data.video.captions.forEach(async (caption) => { @@ -81,10 +73,6 @@ }); } - player.addEventListener('time-update', () => { - currentTime = player.currentTime; - }); - player.addEventListener('pause', () => { savePlayerPos(); }); diff --git a/materialious/src/lib/Thumbnail.svelte b/materialious/src/lib/Thumbnail.svelte index 5c97fbca..e5af7ad7 100644 --- a/materialious/src/lib/Thumbnail.svelte +++ b/materialious/src/lib/Thumbnail.svelte @@ -4,18 +4,24 @@ import { get } from 'svelte/store'; import { deArrowEnabled, + interfacePreviewVideoOnHover, + playerProxyVideos, playerSavePlaybackPosition, syncPartyConnections, syncPartyPeer } from '../store'; import { getDeArrow, getThumbnail, getVideo } from './Api'; - import type { Notification, PlaylistPageVideo, Video, VideoBase } from './Api/model'; + import type { Notification, PlaylistPageVideo, Video, VideoBase, VideoPlay } from './Api/model'; import { cleanNumber, proxyVideoUrl, truncate, videoLength } from './misc'; import type { PlayerEvents } from './player'; export let video: VideoBase | Video | Notification | PlaylistPageVideo; export let playlistId: string = ''; + let showVideoPreview: boolean = false; + let videoPreview: VideoPlay | null = null; + let videoPreviewMuted: boolean = true; + let watchUrl = new URL(`${import.meta.env.VITE_DEFAULT_FRONTEND_URL}/watch/${video.videoId}`); if (playlistId !== '') { @@ -30,7 +36,6 @@ let loading = true; let loaded = false; - let failed = false; let img: HTMLImageElement; @@ -118,7 +123,6 @@ }; img.onerror = () => { loading = false; - failed = true; }; }); @@ -139,47 +143,100 @@ }); } } + + async function previewVideo() { + if (!get(interfacePreviewVideoOnHover)) return; + + showVideoPreview = true; + try { + videoPreview = await getVideo(video.videoId, get(playerProxyVideos)); + } catch { + showVideoPreview = true; + } + } - (showVideoPreview = false)} + on:focus={() => {}} + role="region" > - {#if loading} - - {:else if loaded} - Thumbnail for video - {:else} -

{$_('thumbnail.failedToLoadImage')}

- {/if} - {#if progress} - - {/if} - {#if !('liveVideo' in video) || !video.liveVideo} - {#if video.lengthSeconds !== 0} -
-  {videoLength(video.lengthSeconds)}  + + {#if loading} + + {:else if loaded} + {#if showVideoPreview && videoPreview} +
+ +
+ {:else} + Thumbnail for video + {/if} + {:else} +

{$_('thumbnail.failedToLoadImage')}

+ {/if} + {#if progress} + + {/if} + {#if !('liveVideo' in video) || !video.liveVideo} + {#if video.lengthSeconds !== 0} +
+  {videoLength(video.lengthSeconds)}  +
+ {/if} + {:else} +
+ {$_('thumbnail.live')}
{/if} - {:else} -
- {$_('thumbnail.live')} -
+
+ {#if showVideoPreview && videoPreview} + {/if} - +
+
+ +
+ +
diff --git a/materialious/src/routes/watch/[slug]/+page.svelte b/materialious/src/routes/watch/[slug]/+page.svelte index 12b71d63..5c07109d 100644 --- a/materialious/src/routes/watch/[slug]/+page.svelte +++ b/materialious/src/routes/watch/[slug]/+page.svelte @@ -46,7 +46,6 @@ let theatreMode = get(playerTheatreModeByDefault); let audioMode = get(playerListenByDefault); - let currentTime: number; let seekTo: (time: number) => void; let player: MediaPlayerElement; @@ -357,14 +356,7 @@
{#key data.video.videoId} - + {/key}
{data.video.title}
diff --git a/materialious/src/store.ts b/materialious/src/store.ts index 6004937b..cfb8f54f 100644 --- a/materialious/src/store.ts +++ b/materialious/src/store.ts @@ -24,6 +24,7 @@ export const playerAutoplayNextByDefault = persisted('autoplayNextByDefault', fa export const returnYtDislikes = persisted('returnYtDislikes', true); export const interfaceSearchSuggestions = persisted('searchSuggestions', true); +export const interfacePreviewVideoOnHover = persisted('previewVideoOnHover', true); export const auth: Writable = persisted( 'authToken',