mirror of
https://github.com/owntone/owntone-server.git
synced 2025-07-17 12:42:46 -04:00
49 lines
1.0 KiB
Vue
49 lines
1.0 KiB
Vue
<template>
|
|
<a :disabled="disabled" @click="toggle">
|
|
<mdicon class="icon" :name="icon" :title="$t(`player.button.${icon}`)" />
|
|
</a>
|
|
</template>
|
|
|
|
<script>
|
|
import player from '@/api/player'
|
|
import { usePlayerStore } from '@/stores/player'
|
|
import { useQueueStore } from '@/stores/queue'
|
|
|
|
export default {
|
|
name: 'ControlPlayerPlay',
|
|
setup() {
|
|
return {
|
|
playerStore: usePlayerStore(),
|
|
queueStore: useQueueStore()
|
|
}
|
|
},
|
|
computed: {
|
|
disabled() {
|
|
return this.queueStore?.count <= 0
|
|
},
|
|
icon() {
|
|
if (!this.playerStore.isPlaying) {
|
|
return 'play'
|
|
} else if (this.queueStore.isPauseAllowed) {
|
|
return 'pause'
|
|
}
|
|
return 'stop'
|
|
}
|
|
},
|
|
methods: {
|
|
toggle() {
|
|
if (this.playerStore.isPlaying && this.queueStore.isPauseAllowed) {
|
|
player.pause()
|
|
} else if (
|
|
this.playerStore.isPlaying &&
|
|
!this.queueStore.isPauseAllowed
|
|
) {
|
|
player.stop()
|
|
} else {
|
|
player.play()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|