diff --git a/__tests__/lib/string.test.ts b/__tests__/lib/string.test.ts index edddcb3e..b3aa48f4 100644 --- a/__tests__/lib/string.test.ts +++ b/__tests__/lib/string.test.ts @@ -463,44 +463,44 @@ describe('parseEmbedPlayerFromUrl', () => { type: 'youtube_video', source: 'youtube', playerUri: - 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', + 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0', }, { type: 'youtube_video', source: 'youtube', playerUri: - 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', + 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0', }, { type: 'youtube_video', source: 'youtube', playerUri: - 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', + 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0', }, { type: 'youtube_video', source: 'youtube', playerUri: - 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', + 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0', }, { type: 'youtube_video', source: 'youtube', playerUri: - 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', + 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0', }, { type: 'youtube_short', source: 'youtubeShorts', hideDetails: true, playerUri: - 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', + 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0', }, { type: 'youtube_video', source: 'youtube', playerUri: - 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', + 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0', }, undefined, diff --git a/src/lib/strings/embed-player.ts b/src/lib/strings/embed-player.ts index 0f97eb08..3270b6f0 100644 --- a/src/lib/strings/embed-player.ts +++ b/src/lib/strings/embed-player.ts @@ -68,11 +68,12 @@ export function parseEmbedPlayerFromUrl( // youtube if (urlp.hostname === 'youtu.be') { const videoId = urlp.pathname.split('/')[1] + const seek = encodeURIComponent(urlp.searchParams.get('t') ?? 0) if (videoId) { return { type: 'youtube_video', source: 'youtube', - playerUri: `https://www.youtube.com/embed/${videoId}?autoplay=1&playsinline=1`, + playerUri: `https://www.youtube.com/embed/${videoId}?autoplay=1&playsinline=1&start=${seek}`, } } } @@ -84,13 +85,14 @@ export function parseEmbedPlayerFromUrl( const [_, page, shortVideoId] = urlp.pathname.split('/') const videoId = page === 'shorts' ? shortVideoId : (urlp.searchParams.get('v') as string) + const seek = encodeURIComponent(urlp.searchParams.get('t') ?? 0) if (videoId) { return { type: page === 'shorts' ? 'youtube_short' : 'youtube_video', source: page === 'shorts' ? 'youtubeShorts' : 'youtube', hideDetails: page === 'shorts' ? true : undefined, - playerUri: `https://www.youtube.com/embed/${videoId}?autoplay=1&playsinline=1`, + playerUri: `https://www.youtube.com/embed/${videoId}?autoplay=1&playsinline=1&start=${seek}`, } } }