2018-08-11 01:47:10 -04:00
|
|
|
<template>
|
2019-10-26 03:58:35 -04:00
|
|
|
<a @click="toggle_play_pause" :disabled="disabled">
|
2020-04-18 00:57:55 -04:00
|
|
|
<span class="icon"><i class="mdi" :class="[icon_style, { 'mdi-play': !is_playing, 'mdi-pause': is_playing && is_pause_allowed, 'mdi-stop': is_playing && !is_pause_allowed }]"></i></span>
|
2018-08-11 01:47:10 -04:00
|
|
|
</a>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import webapi from '@/webapi'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'PlayerButtonPlayPause',
|
|
|
|
|
2019-10-26 03:58:35 -04:00
|
|
|
props: {
|
2020-04-11 13:43:53 -04:00
|
|
|
icon_style: String,
|
|
|
|
show_disabled_message: Boolean
|
2019-10-26 03:58:35 -04:00
|
|
|
},
|
2018-08-11 01:47:10 -04:00
|
|
|
|
|
|
|
computed: {
|
|
|
|
is_playing () {
|
|
|
|
return this.$store.state.player.state === 'play'
|
2018-12-30 02:53:40 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
is_pause_allowed () {
|
2019-06-15 07:26:18 -04:00
|
|
|
return (this.$store.getters.now_playing &&
|
|
|
|
this.$store.getters.now_playing.data_kind !== 'pipe')
|
2019-10-26 03:58:35 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
disabled () {
|
|
|
|
return !this.$store.state.queue || this.$store.state.queue.count <= 0
|
2018-08-11 01:47:10 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
toggle_play_pause: function () {
|
2019-10-26 03:58:35 -04:00
|
|
|
if (this.disabled) {
|
|
|
|
if (this.show_disabled_message) {
|
|
|
|
this.$store.dispatch('add_notification', { text: 'Queue is empty', type: 'info', topic: 'connection', timeout: 2000 })
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-12-30 02:53:40 -05:00
|
|
|
if (this.is_playing && this.is_pause_allowed) {
|
2018-08-11 01:47:10 -04:00
|
|
|
webapi.player_pause()
|
2018-12-30 02:53:40 -05:00
|
|
|
} else if (this.is_playing && !this.is_pause_allowed) {
|
|
|
|
webapi.player_stop()
|
2018-08-11 01:47:10 -04:00
|
|
|
} else {
|
|
|
|
webapi.player_play()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
</style>
|