2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2022-04-21 10:43:10 +00:00
|
|
|
<li :class="{ available: song }" :title="tooltip" role="button" tabindex="0" @click="play">
|
2022-04-15 14:24:30 +00:00
|
|
|
<span class="title">{{ track.title }}</span>
|
|
|
|
<a
|
|
|
|
v-if="useiTunes && !song"
|
2022-04-21 10:43:10 +00:00
|
|
|
:href="iTunesUrl"
|
2022-04-15 14:24:30 +00:00
|
|
|
class="view-on-itunes"
|
2022-04-21 10:43:10 +00:00
|
|
|
target="_blank"
|
2022-04-15 14:24:30 +00:00
|
|
|
title="View on iTunes"
|
|
|
|
>
|
|
|
|
iTunes
|
|
|
|
</a>
|
|
|
|
<span class="length">{{ track.fmtLength }}</span>
|
|
|
|
</li>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-04-30 14:05:02 +00:00
|
|
|
import { computed, toRefs } from 'vue'
|
|
|
|
import { queueStore, songStore } from '@/stores'
|
2022-04-24 08:50:45 +00:00
|
|
|
import { authService, playbackService } from '@/services'
|
2022-04-30 14:05:02 +00:00
|
|
|
import { useThirdPartyServices } from '@/composables'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-21 10:43:10 +00:00
|
|
|
const props = defineProps<{ album: Album, track: AlbumTrack }>()
|
|
|
|
const { album, track } = toRefs(props)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-30 14:05:02 +00:00
|
|
|
const { useiTunes } = useThirdPartyServices()
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const song = computed(() => songStore.guess(track.value.title, album.value))
|
|
|
|
const tooltip = computed(() => song.value ? 'Click to play' : '')
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const iTunesUrl = computed(() => {
|
2022-04-24 08:50:45 +00:00
|
|
|
return `${window.BASE_URL}itunes/song/${album.value.id}?q=${encodeURIComponent(track.value.title)}&api_token=${authService.getToken()}`
|
2022-04-15 17:00:08 +00:00
|
|
|
})
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const play = () => {
|
|
|
|
if (song.value) {
|
2022-04-23 22:31:40 +00:00
|
|
|
queueStore.queueIfNotQueued(song.value)
|
2022-04-24 08:50:45 +00:00
|
|
|
playbackService.play(song.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
[role=button] {
|
|
|
|
&:focus {
|
|
|
|
span.title {
|
|
|
|
color: var(--color-highlight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
a.view-on-itunes {
|
|
|
|
display: inline-block;
|
|
|
|
border-radius: 3px;
|
|
|
|
font-size: .8rem;
|
|
|
|
padding: 0 5px;
|
|
|
|
color: var(--color-text-primary);
|
|
|
|
background: rgba(255, 255, 255, .1);
|
|
|
|
height: 20px;
|
|
|
|
line-height: 20px;
|
|
|
|
margin-left: 4px;
|
|
|
|
|
|
|
|
&:hover, &:focus {
|
2022-04-15 17:00:08 +00:00
|
|
|
background: linear-gradient(27deg, #fe5c52 0%, #c74bd5 50%, #2daaff 100%);
|
2022-04-15 14:24:30 +00:00
|
|
|
color: var(--color-text-primary);
|
|
|
|
}
|
|
|
|
|
|
|
|
&:active {
|
|
|
|
box-shadow: inset 0px 5px 5px -5px #000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|