2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<div class="side player-controls">
|
|
|
|
<i
|
|
|
|
class="prev fa fa-step-backward control"
|
2022-05-13 12:40:04 +00:00
|
|
|
data-testid="play-prev-btn"
|
2022-04-15 14:24:30 +00:00
|
|
|
role="button"
|
|
|
|
tabindex="0"
|
|
|
|
title="Play previous song"
|
2022-05-05 14:56:31 +00:00
|
|
|
@click.prevent="playPrev"
|
2022-04-15 14:24:30 +00:00
|
|
|
/>
|
|
|
|
|
|
|
|
<span class="album-thumb-wrapper">
|
|
|
|
<span :style="{ backgroundImage: `url('${cover}')` }" class="album-thumb"></span>
|
|
|
|
<span
|
2022-05-05 14:56:31 +00:00
|
|
|
v-if="shouldShowPlayButton"
|
2022-04-15 14:24:30 +00:00
|
|
|
class="play"
|
2022-05-13 12:40:04 +00:00
|
|
|
data-testid="play-btn"
|
2022-04-15 14:24:30 +00:00
|
|
|
role="button"
|
|
|
|
tabindex="0"
|
|
|
|
title="Play or resume"
|
2022-05-05 14:56:31 +00:00
|
|
|
@click.prevent="toggle"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
|
|
|
<i class="fa fa-play"></i>
|
|
|
|
</span>
|
|
|
|
<span
|
2022-05-05 14:56:31 +00:00
|
|
|
v-else
|
2022-04-15 14:24:30 +00:00
|
|
|
class="pause"
|
2022-05-05 14:56:31 +00:00
|
|
|
data-testid="pause-btn"
|
2022-04-15 14:24:30 +00:00
|
|
|
role="button"
|
|
|
|
tabindex="0"
|
|
|
|
title="Pause"
|
2022-05-05 14:56:31 +00:00
|
|
|
@click.prevent="toggle"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
|
|
|
<i class="fa fa-pause"></i>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<i
|
|
|
|
class="next fa fa-step-forward control"
|
2022-05-13 12:40:04 +00:00
|
|
|
data-testid="play-next-btn"
|
2022-04-15 14:24:30 +00:00
|
|
|
role="button"
|
|
|
|
tabindex="0"
|
|
|
|
title="Play next song"
|
2022-05-05 14:56:31 +00:00
|
|
|
@click.prevent="playNext"
|
2022-04-15 14:24:30 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed, toRefs } from 'vue'
|
2022-04-24 08:50:45 +00:00
|
|
|
import { playbackService } from '@/services'
|
2022-04-24 18:07:14 +00:00
|
|
|
import { defaultCover } from '@/utils'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const props = defineProps<{ song: Song | null }>()
|
|
|
|
const { song } = toRefs(props)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
const cover = computed(() => song.value?.album_cover ? song.value?.album_cover : defaultCover)
|
|
|
|
const shouldShowPlayButton = computed(() => !song || song.value?.playback_state !== 'Playing')
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-24 08:50:45 +00:00
|
|
|
const playPrev = async () => await playbackService.playPrev()
|
|
|
|
const playNext = async () => await playbackService.playNext()
|
|
|
|
const toggle = async () => await playbackService.toggle()
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.player-controls {
|
|
|
|
@include vertical-center();
|
|
|
|
flex: 0 0 256px;
|
|
|
|
font-size: 1.8rem;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
.album-thumb-wrapper {
|
|
|
|
margin-left: 1rem;
|
|
|
|
margin-right: 1rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.album-thumb {
|
|
|
|
filter: brightness(.4);
|
|
|
|
}
|
|
|
|
|
|
|
|
.prev, .next {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.play, .pause {
|
|
|
|
opacity: .7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.album-thumb-wrapper {
|
|
|
|
flex: 0 0 calc(var(--footer-height) + 30px);
|
|
|
|
height: calc(var(--footer-height) + 30px);
|
|
|
|
transition: .2s ease-out;
|
|
|
|
position: relative;
|
|
|
|
overflow: hidden;
|
|
|
|
border-radius: 50%;
|
|
|
|
box-shadow: 0 0 20px rgba(0, 0, 0, .2);
|
|
|
|
margin-left: -3rem;
|
|
|
|
margin-right: -3rem;
|
|
|
|
|
|
|
|
@media (hover: none) {
|
|
|
|
margin-left: 1rem;
|
|
|
|
margin-right: 1rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
@include vertical-center();
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
.album-thumb {
|
|
|
|
transform: scale(1.1);
|
|
|
|
|
|
|
|
&::after {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.play, .pause {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.album-thumb {
|
|
|
|
position: relative;
|
|
|
|
background-color: transparent;
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
left: 0;
|
|
|
|
top: 0;
|
|
|
|
z-index: 0;
|
|
|
|
border-radius: 50%;
|
|
|
|
background-size: cover;
|
|
|
|
transition: .2s ease-out;
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
&::after {
|
|
|
|
content: "";
|
|
|
|
position: absolute;
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
2022-04-15 17:00:08 +00:00
|
|
|
background: linear-gradient(135deg, rgba(235, 241, 246, 0) 0%, rgba(255, 255, 255, .3) 41%, rgba(255, 255, 255, 0) 41%);
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.prev, .next {
|
|
|
|
transition: .4s ease-out;
|
|
|
|
opacity: 0;
|
|
|
|
padding: 1rem;
|
|
|
|
margin: -.75rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.play, .pause {
|
|
|
|
@include inset-when-pressed();
|
|
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
transition: opacity .4s ease-out;
|
|
|
|
font-size: 3rem;
|
|
|
|
display: inline-block;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
line-height: calc(var(--footer-height) + 30px);
|
|
|
|
text-align: center;
|
|
|
|
text-indent: 2px;
|
|
|
|
color: var(--color-text-primary);
|
|
|
|
opacity: 0;
|
|
|
|
text-shadow: 0 0 1px rgba(0, 0, 0, 0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
.pause {
|
|
|
|
text-indent: 0;
|
|
|
|
font-size: 2rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.enabled {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media only screen and (max-width: 768px) {
|
|
|
|
flex: 1;
|
|
|
|
|
|
|
|
&::before {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.album-thumb-wrapper {
|
|
|
|
flex: 0 0 48px;
|
|
|
|
height: 48px;
|
|
|
|
box-shadow: 0 0 0 1px var(--color-text-secondary);
|
|
|
|
}
|
|
|
|
|
|
|
|
.album-thumb {
|
|
|
|
background-image: none !important;
|
|
|
|
|
|
|
|
&::after {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.play, .pause {
|
|
|
|
line-height: 48px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.prev, .next, .play, .pause {
|
|
|
|
opacity: 1;
|
|
|
|
font-size: 2rem;
|
|
|
|
color: var(--color-text-secondary);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|