mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-27 06:33:21 -05:00
[web-src] Disable play/pause/etc. buttons if queue is empty
This commit is contained in:
parent
e8ead500c5
commit
7a236a21b8
@ -12,7 +12,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</router-link>
|
</router-link>
|
||||||
<player-button-play-pause class="navbar-item fd-margin-left-auto" icon_style="mdi-36px"></player-button-play-pause>
|
<player-button-play-pause class="navbar-item fd-margin-left-auto" icon_style="mdi-36px" show_disabled_message></player-button-play-pause>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</template>
|
</template>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<a v-on:click="play_next">
|
<a v-on:click="play_next" :disabled="disabled">
|
||||||
<span class="icon"><i class="mdi mdi-skip-forward"></i></span>
|
<span class="icon"><i class="mdi mdi-skip-forward"></i></span>
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
@ -10,8 +10,18 @@ import webapi from '@/webapi'
|
|||||||
export default {
|
export default {
|
||||||
name: 'PlayerButtonNext',
|
name: 'PlayerButtonNext',
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
disabled () {
|
||||||
|
return !this.$store.state.queue || this.$store.state.queue.count <= 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
play_next: function () {
|
play_next: function () {
|
||||||
|
if (this.disabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
webapi.player_next()
|
webapi.player_next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<a v-on:click="toggle_play_pause">
|
<a @click="toggle_play_pause" :disabled="disabled">
|
||||||
<span class="icon"><i class="mdi" v-bind:class="[icon_style, { 'mdi-play': !is_playing, 'mdi-pause': is_playing && is_pause_allowed, 'mdi-stop': is_playing && !is_pause_allowed }]"></i></span>
|
<span class="icon"><i class="mdi" v-bind:class="[icon_style, { 'mdi-play': !is_playing, 'mdi-pause': is_playing && is_pause_allowed, 'mdi-stop': is_playing && !is_pause_allowed }]"></i></span>
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
@ -10,7 +10,10 @@ import webapi from '@/webapi'
|
|||||||
export default {
|
export default {
|
||||||
name: 'PlayerButtonPlayPause',
|
name: 'PlayerButtonPlayPause',
|
||||||
|
|
||||||
props: ['icon_style'],
|
props: {
|
||||||
|
'icon_style': String,
|
||||||
|
'show_disabled_message': Boolean
|
||||||
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
is_playing () {
|
is_playing () {
|
||||||
@ -20,11 +23,22 @@ export default {
|
|||||||
is_pause_allowed () {
|
is_pause_allowed () {
|
||||||
return (this.$store.getters.now_playing &&
|
return (this.$store.getters.now_playing &&
|
||||||
this.$store.getters.now_playing.data_kind !== 'pipe')
|
this.$store.getters.now_playing.data_kind !== 'pipe')
|
||||||
|
},
|
||||||
|
|
||||||
|
disabled () {
|
||||||
|
return !this.$store.state.queue || this.$store.state.queue.count <= 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
toggle_play_pause: function () {
|
toggle_play_pause: function () {
|
||||||
|
if (this.disabled) {
|
||||||
|
if (this.show_disabled_message) {
|
||||||
|
this.$store.dispatch('add_notification', { text: 'Queue is empty', type: 'info', topic: 'connection', timeout: 2000 })
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (this.is_playing && this.is_pause_allowed) {
|
if (this.is_playing && this.is_pause_allowed) {
|
||||||
webapi.player_pause()
|
webapi.player_pause()
|
||||||
} else if (this.is_playing && !this.is_pause_allowed) {
|
} else if (this.is_playing && !this.is_pause_allowed) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<a v-on:click="play_previous">
|
<a v-on:click="play_previous" :disabled="disabled">
|
||||||
<span class="icon"><i class="mdi mdi-skip-backward"></i></span>
|
<span class="icon"><i class="mdi mdi-skip-backward"></i></span>
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
@ -10,8 +10,18 @@ import webapi from '@/webapi'
|
|||||||
export default {
|
export default {
|
||||||
name: 'PlayerButtonPrevious',
|
name: 'PlayerButtonPrevious',
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
disabled () {
|
||||||
|
return !this.$store.state.queue || this.$store.state.queue.count <= 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
play_previous: function () {
|
play_previous: function () {
|
||||||
|
if (this.disabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
webapi.player_previous()
|
webapi.player_previous()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user