From 3acdd0f8a561c2eb74f3a362cd78eb695b826730 Mon Sep 17 00:00:00 2001 From: JSC Date: Fri, 18 Jul 2025 22:56:09 +0200 Subject: [PATCH] feat: add timestamp functionality to service URLs in MusicPlayer --- src/components/MusicPlayer.tsx | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/components/MusicPlayer.tsx b/src/components/MusicPlayer.tsx index bd762b5..0dceda4 100644 --- a/src/components/MusicPlayer.tsx +++ b/src/components/MusicPlayer.tsx @@ -66,6 +66,23 @@ export function MusicPlayer() { return null } + const openServiceUrlWithTimestamp = (serviceUrl: string) => { + let urlWithTimestamp = serviceUrl + const currentTimeInSeconds = Math.floor(currentTime / 1000) + const separator = serviceUrl.includes('?') ? '&' : '?' + + // Add timestamp parameter based on service type + if (serviceUrl.includes('youtube.com') || serviceUrl.includes('youtu.be')) { + // YouTube timestamp format: &t=123s or ?t=123s + urlWithTimestamp = `${serviceUrl}${separator}t=${currentTimeInSeconds}s` + } else { + // For other services, try common timestamp parameter + urlWithTimestamp = serviceUrl + } + + window.open(urlWithTimestamp, '_blank') + } + const handleVolumeChange = (e: React.ChangeEvent) => { const newVolume = parseFloat(e.target.value) setVolume(newVolume) @@ -184,7 +201,7 @@ export function MusicPlayer() { )} {currentTrack?.service_url && ( - window.open(currentTrack.service_url, '_blank')}> + openServiceUrlWithTimestamp(currentTrack.service_url!)}> Open Service @@ -367,7 +384,7 @@ export function MusicPlayer() { )} {currentTrack?.service_url && ( - window.open(currentTrack.service_url, '_blank')}> + openServiceUrlWithTimestamp(currentTrack.service_url!)}> Open Service