2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<div class="other-controls" data-testid="other-controls">
|
2022-04-20 15:57:53 +00:00
|
|
|
<div v-koel-clickaway="closeEqualizer" class="wrapper">
|
|
|
|
<Equalizer v-show="showEqualizer" v-if="useEqualizer"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
|
|
<button
|
2022-04-20 15:57:53 +00:00
|
|
|
v-if="song?.playbackState === 'Playing'"
|
2022-04-15 14:24:30 +00:00
|
|
|
data-testid="toggle-visualizer-btn"
|
2022-04-20 15:57:53 +00:00
|
|
|
title="Click for a marvelous visualizer!"
|
|
|
|
type="button"
|
|
|
|
@click.prevent="toggleVisualizer"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
2022-04-20 15:57:53 +00:00
|
|
|
<SoundBar data-testid="sound-bar-play"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</button>
|
|
|
|
|
2022-04-20 15:57:53 +00:00
|
|
|
<LikeButton v-if="song" :song="song" class="like"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
|
|
<button
|
2022-04-20 15:57:53 +00:00
|
|
|
:class="{ active: showExtraPanel }"
|
2022-04-15 14:24:30 +00:00
|
|
|
class="control text-uppercase"
|
|
|
|
data-testid="toggle-extra-panel-btn"
|
2022-04-20 15:57:53 +00:00
|
|
|
title="View song information"
|
|
|
|
type="button"
|
|
|
|
@click.prevent="toggleExtraPanel"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
|
|
|
Info
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<button
|
|
|
|
v-if="useEqualizer"
|
|
|
|
:class="{ active: showEqualizer }"
|
2022-04-20 15:57:53 +00:00
|
|
|
:title="`${ showEqualizer ? 'Hide' : 'Show'} equalizer`"
|
|
|
|
class="control equalizer"
|
2022-04-15 14:24:30 +00:00
|
|
|
data-testid="toggle-equalizer-btn"
|
2022-04-20 15:57:53 +00:00
|
|
|
type="button"
|
|
|
|
@click.prevent="toggleEqualizer"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
|
|
|
<i class="fa fa-sliders"></i>
|
|
|
|
</button>
|
|
|
|
|
2022-04-20 15:57:53 +00:00
|
|
|
<a v-else :class="{ active: viewingQueue }" class="queue control" href="#!/queue">
|
2022-04-15 14:24:30 +00:00
|
|
|
<i class="fa fa-list-ol"></i>
|
|
|
|
</a>
|
|
|
|
|
2022-04-20 15:57:53 +00:00
|
|
|
<RepeatModeSwitch/>
|
|
|
|
<Volume/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-04-20 15:57:53 +00:00
|
|
|
import { defineAsyncComponent, reactive, ref, toRef, toRefs } from 'vue'
|
|
|
|
import isMobile from 'ismobilejs'
|
2022-04-15 14:24:30 +00:00
|
|
|
import { socket } from '@/services'
|
2022-04-15 17:00:08 +00:00
|
|
|
import { eventBus, isAudioContextSupported as useEqualizer } from '@/utils'
|
2022-04-20 15:57:53 +00:00
|
|
|
import { favoriteStore, preferenceStore, songStore } from '@/stores'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-20 15:57:53 +00:00
|
|
|
const Equalizer = defineAsyncComponent(() => import('@/components/ui/Equalizer.vue'))
|
2022-04-15 17:00:08 +00:00
|
|
|
const SoundBar = defineAsyncComponent(() => import('@/components/ui/sound-bar.vue'))
|
2022-04-20 15:57:53 +00:00
|
|
|
const Volume = defineAsyncComponent(() => import('@/components/ui/Volume.vue'))
|
|
|
|
const LikeButton = defineAsyncComponent(() => import('@/components/song/SongLikeButton.vue'))
|
|
|
|
const RepeatModeSwitch = defineAsyncComponent(() => import('@/components/ui/RepeatModeSwitch.vue'))
|
2022-04-15 17:00:08 +00:00
|
|
|
|
|
|
|
const props = defineProps<{ song: Song }>()
|
|
|
|
const { song } = toRefs(props)
|
|
|
|
|
2022-04-20 15:57:53 +00:00
|
|
|
const showExtraPanel = toRef(preferenceStore.state, 'showExtraPanel')
|
2022-04-15 17:00:08 +00:00
|
|
|
const showEqualizer = ref(false)
|
|
|
|
const viewingQueue = ref(false)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const like = () => {
|
|
|
|
if (song.value.id) {
|
|
|
|
favoriteStore.toggleOne(song.value)
|
|
|
|
socket.broadcast('SOCKET_SONG', songStore.generateDataToBroadcast(song.value))
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
|
|
|
|
2022-04-20 15:57:53 +00:00
|
|
|
const toggleExtraPanel = () => (preferenceStore.showExtraPanel = !showExtraPanel.value)
|
2022-04-15 17:00:08 +00:00
|
|
|
const toggleEqualizer = () => (showEqualizer.value = !showEqualizer.value)
|
|
|
|
const closeEqualizer = () => showEqualizer.value = false
|
|
|
|
const toggleVisualizer = () => isMobile.any || eventBus.emit('TOGGLE_VISUALIZER')
|
|
|
|
|
|
|
|
eventBus.on('LOAD_MAIN_CONTENT', (view: MainViewName) => (viewingQueue.value = view === 'Queue'))
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.other-controls {
|
|
|
|
@include vertical-center();
|
|
|
|
|
|
|
|
position: relative;
|
|
|
|
flex: 0 0 var(--extra-panel-width);
|
|
|
|
color: var(--color-text-secondary);
|
|
|
|
|
|
|
|
.wrapper {
|
|
|
|
@include vertical-center();
|
|
|
|
|
|
|
|
> * + * {
|
|
|
|
margin-left: 1rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.control {
|
|
|
|
&.active {
|
|
|
|
color: var(--color-highlight);
|
|
|
|
}
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
padding-right: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@media only screen and (max-width: 768px) {
|
|
|
|
position: absolute !important;
|
|
|
|
right: 0;
|
|
|
|
top: 0;
|
|
|
|
height: 100%;
|
|
|
|
width: 188px;
|
|
|
|
|
|
|
|
&::before {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.queue {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
> * + * {
|
|
|
|
margin-left: 1.5rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|