feat: add timestamp functionality to service URLs in MusicPlayer
This commit is contained in:
@@ -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<HTMLInputElement>) => {
|
||||
const newVolume = parseFloat(e.target.value)
|
||||
setVolume(newVolume)
|
||||
@@ -184,7 +201,7 @@ export function MusicPlayer() {
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{currentTrack?.service_url && (
|
||||
<DropdownMenuItem onClick={() => window.open(currentTrack.service_url, '_blank')}>
|
||||
<DropdownMenuItem onClick={() => openServiceUrlWithTimestamp(currentTrack.service_url!)}>
|
||||
<Globe className="h-3 w-3" />
|
||||
Open Service
|
||||
</DropdownMenuItem>
|
||||
@@ -367,7 +384,7 @@ export function MusicPlayer() {
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
{currentTrack?.service_url && (
|
||||
<DropdownMenuItem onClick={() => window.open(currentTrack.service_url, '_blank')}>
|
||||
<DropdownMenuItem onClick={() => openServiceUrlWithTimestamp(currentTrack.service_url!)}>
|
||||
<Globe className="h-4 w-4" />
|
||||
Open Service
|
||||
</DropdownMenuItem>
|
||||
|
||||
Reference in New Issue
Block a user