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