Add track position
This commit is contained in:
parent
8c62d516b0
commit
db932f2470
|
@ -31,6 +31,7 @@ export interface QueueTrack {
|
||||||
title: string
|
title: string
|
||||||
artistName: string
|
artistName: string
|
||||||
albumTitle: string
|
albumTitle: string
|
||||||
|
position?: number
|
||||||
|
|
||||||
// TODO: Add urls for those
|
// TODO: Add urls for those
|
||||||
coverUrl: string
|
coverUrl: string
|
||||||
|
@ -109,10 +110,9 @@ export const useQueue = createGlobalState(() => {
|
||||||
return {
|
return {
|
||||||
id: track.id,
|
id: track.id,
|
||||||
title: track.title,
|
title: track.title,
|
||||||
// TODO (wvffle): i18n
|
|
||||||
artistName: track.artist?.name ?? $pgettext('*/*/*', 'Unknown artist'),
|
artistName: track.artist?.name ?? $pgettext('*/*/*', 'Unknown artist'),
|
||||||
// TODO (wvffle): i18n
|
|
||||||
albumTitle: track.album?.title ?? $pgettext('*/*/*', 'Unknown album'),
|
albumTitle: track.album?.title ?? $pgettext('*/*/*', 'Unknown album'),
|
||||||
|
position: track.position,
|
||||||
artistId: track.artist?.id ?? -1,
|
artistId: track.artist?.id ?? -1,
|
||||||
albumId: track.album?.id ?? -1,
|
albumId: track.album?.id ?? -1,
|
||||||
coverUrl: (track.cover?.urls ?? track.album?.cover?.urls ?? track.artist?.cover?.urls)?.original
|
coverUrl: (track.cover?.urls ?? track.album?.cover?.urls ?? track.artist?.cover?.urls)?.original
|
||||||
|
@ -171,7 +171,7 @@ export const useQueue = createGlobalState(() => {
|
||||||
if (currentIndex.value !== trackIndex) currentSound.value?.seekTo(0)
|
if (currentIndex.value !== trackIndex) currentSound.value?.seekTo(0)
|
||||||
|
|
||||||
const shouldRestart = forceRestartIfCurrent && currentIndex.value === trackIndex
|
const shouldRestart = forceRestartIfCurrent && currentIndex.value === trackIndex
|
||||||
const nextTrackIsTheSame = queue.value[trackIndex].id === currentTrack.value.id
|
const nextTrackIsTheSame = queue.value[trackIndex]?.id === currentTrack.value?.id
|
||||||
|
|
||||||
if (shouldRestart || nextTrackIsTheSame) {
|
if (shouldRestart || nextTrackIsTheSame) {
|
||||||
currentSound.value?.seekTo(0)
|
currentSound.value?.seekTo(0)
|
||||||
|
|
|
@ -176,8 +176,7 @@ export default (props: PlayOptionsProps) => {
|
||||||
addMessage(tracksToPlay)
|
addMessage(tracksToPlay)
|
||||||
}
|
}
|
||||||
|
|
||||||
const activateTrack = async (track: Track, index: number) => {
|
const activateTrack = async (track: Track) => {
|
||||||
// TODO (wvffle): Check if position checking did not break anything
|
|
||||||
if (track.id === currentTrack.value?.id && track.position === currentTrack.value?.position) {
|
if (track.id === currentTrack.value?.id && track.position === currentTrack.value?.position) {
|
||||||
isPlaying.value = true
|
isPlaying.value = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue