From 0f863bea647a3002141a893ead20bd767327e0a0 Mon Sep 17 00:00:00 2001 From: WardPearce Date: Sat, 13 Apr 2024 19:24:53 +1200 Subject: [PATCH] Get video volume for preview --- materialious/src/lib/Thumbnail.svelte | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/materialious/src/lib/Thumbnail.svelte b/materialious/src/lib/Thumbnail.svelte index 6bb08a03..592141d5 100644 --- a/materialious/src/lib/Thumbnail.svelte +++ b/materialious/src/lib/Thumbnail.svelte @@ -21,6 +21,7 @@ let showVideoPreview: boolean = false; let videoPreview: VideoPlay | null = null; let videoPreviewMuted: boolean = true; + let videoPreviewVolume: number = 0.4; let watchUrl = new URL(`${import.meta.env.VITE_DEFAULT_FRONTEND_URL}/watch/${video.videoId}`); @@ -153,6 +154,13 @@ if (videoPreview.hlsUrl) { showVideoPreview = false; videoPreview = null; + } else { + try { + const playerSettings = localStorage.getItem('video-player'); + if (playerSettings && typeof playerSettings === 'object' && 'volume' in playerSettings) { + videoPreviewVolume = Number(playerSettings['volume']); + } + } catch {} } } catch { showVideoPreview = true; @@ -185,7 +193,8 @@ width="100%" height="100%" muted={videoPreviewMuted} - volume={0.5} + controls={false} + volume={videoPreviewVolume} src={videoPreview.formatStreams[0].url} > @@ -250,8 +259,10 @@ style="display: flex; justify-content:flex-start; position: absolute; width: 100%;" >
{video.title} -
+ + +
{video.title}
+
{video.author}{#if !('publishedText' in video) && 'viewCountText' in video}