mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Add:Local setting for autoplay next item in queue #603
This commit is contained in:
parent
772c7b3217
commit
dee4ca3559
@ -148,8 +148,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
mediaFinished(libraryItemId, episodeId) { // Play next item in queue
|
mediaFinished(libraryItemId, episodeId) {
|
||||||
if (!this.playerQueueItems.length) return
|
// Play next item in queue
|
||||||
|
if (!this.playerQueueItems.length || !this.$store.state.playerQueueAutoPlay) {
|
||||||
|
// TODO: Set media finished flag so play button will play next queue item
|
||||||
|
return
|
||||||
|
}
|
||||||
var currentQueueIndex = this.playerQueueItems.findIndex((i) => {
|
var currentQueueIndex = this.playerQueueItems.findIndex((i) => {
|
||||||
if (episodeId) return i.libraryItemId === libraryItemId && i.episodeId === episodeId
|
if (episodeId) return i.libraryItemId === libraryItemId && i.episodeId === episodeId
|
||||||
return i.libraryItemId === libraryItemId
|
return i.libraryItemId === libraryItemId
|
||||||
|
@ -669,6 +669,7 @@ export default {
|
|||||||
|
|
||||||
if (fullLibraryItem && fullLibraryItem.media.episodes) {
|
if (fullLibraryItem && fullLibraryItem.media.episodes) {
|
||||||
const episodes = fullLibraryItem.media.episodes || []
|
const episodes = fullLibraryItem.media.episodes || []
|
||||||
|
episodes.sort((a, b) => b.publishedAt - a.publishedAt)
|
||||||
const episodeIndex = episodes.findIndex((ep) => ep.id === this.recentEpisode.id)
|
const episodeIndex = episodes.findIndex((ep) => ep.id === this.recentEpisode.id)
|
||||||
if (episodeIndex >= 0) {
|
if (episodeIndex >= 0) {
|
||||||
for (let i = episodeIndex; i < episodes.length; i++) {
|
for (let i = episodeIndex; i < episodes.length; i++) {
|
||||||
|
@ -7,6 +7,12 @@
|
|||||||
</template>
|
</template>
|
||||||
<div ref="container" class="w-full rounded-lg bg-bg box-shadow-md overflow-y-auto overflow-x-hidden py-4" style="max-height: 80vh">
|
<div ref="container" class="w-full rounded-lg bg-bg box-shadow-md overflow-y-auto overflow-x-hidden py-4" style="max-height: 80vh">
|
||||||
<div v-if="show" class="w-full h-full">
|
<div v-if="show" class="w-full h-full">
|
||||||
|
<div class="pb-4 px-4 flex items-center">
|
||||||
|
<p class="text-base text-gray-200">Player Queue</p>
|
||||||
|
<p class="text-base text-gray-400 px-4">{{ playerQueueItems.length }} Items</p>
|
||||||
|
<div class="flex-grow" />
|
||||||
|
<ui-checkbox v-model="playerQueueAutoPlay" label="Auto Play" medium checkbox-bg="primary" border-color="gray-600" label-class="pl-2 mb-px" />
|
||||||
|
</div>
|
||||||
<modals-player-queue-item-row v-for="(item, index) in playerQueueItems" :key="index" :item="item" :index="index" @play="playItem" @remove="removeItem" />
|
<modals-player-queue-item-row v-for="(item, index) in playerQueueItems" :key="index" :item="item" :index="index" @play="playItem" @remove="removeItem" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -31,6 +37,14 @@ export default {
|
|||||||
this.$emit('input', val)
|
this.$emit('input', val)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
playerQueueAutoPlay: {
|
||||||
|
get() {
|
||||||
|
return this.$store.state.playerQueueAutoPlay
|
||||||
|
},
|
||||||
|
set(val) {
|
||||||
|
this.$store.commit('setPlayerQueueAutoPlay', val)
|
||||||
|
}
|
||||||
|
},
|
||||||
playerQueueItems() {
|
playerQueueItems() {
|
||||||
return this.$store.state.playerQueueItems || []
|
return this.$store.state.playerQueueItems || []
|
||||||
}
|
}
|
||||||
|
@ -55,9 +55,10 @@ export default {
|
|||||||
},
|
},
|
||||||
labelClassname() {
|
labelClassname() {
|
||||||
if (this.labelClass) return this.labelClass
|
if (this.labelClass) return this.labelClass
|
||||||
var classes = ['pl-1']
|
var classes = []
|
||||||
if (this.small) classes.push('text-xs md:text-sm')
|
if (this.small) classes.push('text-xs md:text-sm pl-1')
|
||||||
else if (this.medium) classes.push('text-base md:text-lg')
|
else if (this.medium) classes.push('text-base md:text-lg pl-2')
|
||||||
|
else classes.push('pl-2')
|
||||||
return classes.join(' ')
|
return classes.join(' ')
|
||||||
},
|
},
|
||||||
svgClass() {
|
svgClass() {
|
||||||
|
@ -522,6 +522,17 @@ export default {
|
|||||||
if (res && res.hasUpdate) this.showUpdateToast(res)
|
if (res && res.hasUpdate) this.showUpdateToast(res)
|
||||||
})
|
})
|
||||||
.catch((err) => console.error(err))
|
.catch((err) => console.error(err))
|
||||||
|
},
|
||||||
|
initLocalStorage() {
|
||||||
|
// If experimental features set in local storage
|
||||||
|
var experimentalFeaturesSaved = localStorage.getItem('experimental')
|
||||||
|
if (experimentalFeaturesSaved === '1') {
|
||||||
|
this.$store.commit('setExperimentalFeatures', true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Queue auto play
|
||||||
|
var playerQueueAutoPlay = localStorage.getItem('playerQueueAutoPlay')
|
||||||
|
this.$store.commit('setPlayerQueueAutoPlay', playerQueueAutoPlay !== '0')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeMount() {
|
beforeMount() {
|
||||||
@ -535,11 +546,7 @@ export default {
|
|||||||
|
|
||||||
this.$store.dispatch('libraries/load')
|
this.$store.dispatch('libraries/load')
|
||||||
|
|
||||||
// If experimental features set in local storage
|
this.initLocalStorage()
|
||||||
var experimentalFeaturesSaved = localStorage.getItem('experimental')
|
|
||||||
if (experimentalFeaturesSaved === '1') {
|
|
||||||
this.$store.commit('setExperimentalFeatures', true)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.checkVersionUpdate()
|
this.checkVersionUpdate()
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ export const state = () => ({
|
|||||||
streamEpisodeId: null,
|
streamEpisodeId: null,
|
||||||
streamIsPlaying: false,
|
streamIsPlaying: false,
|
||||||
playerQueueItems: [],
|
playerQueueItems: [],
|
||||||
|
playerQueueAutoPlay: true,
|
||||||
playerIsFullscreen: false,
|
playerIsFullscreen: false,
|
||||||
editModalTab: 'details',
|
editModalTab: 'details',
|
||||||
showEditModal: false,
|
showEditModal: false,
|
||||||
@ -158,6 +159,10 @@ export const mutations = {
|
|||||||
setPlayerQueueItems(state, items) {
|
setPlayerQueueItems(state, items) {
|
||||||
state.playerQueueItems = items || []
|
state.playerQueueItems = items || []
|
||||||
},
|
},
|
||||||
|
setPlayerQueueAutoPlay(state, autoPlay) {
|
||||||
|
state.playerQueueAutoPlay = !!autoPlay
|
||||||
|
localStorage.setItem('playerQueueAutoPlay', !!autoPlay ? '1' : '0')
|
||||||
|
},
|
||||||
showEditModal(state, libraryItem) {
|
showEditModal(state, libraryItem) {
|
||||||
state.editModalTab = 'details'
|
state.editModalTab = 'details'
|
||||||
state.selectedLibraryItem = libraryItem
|
state.selectedLibraryItem = libraryItem
|
||||||
|
@ -19,7 +19,8 @@ module.exports = {
|
|||||||
'min-w-5',
|
'min-w-5',
|
||||||
'w-3.5',
|
'w-3.5',
|
||||||
'h-3.5',
|
'h-3.5',
|
||||||
'border-warning'
|
'border-warning',
|
||||||
|
'mb-px'
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
theme: {
|
theme: {
|
||||||
|
Loading…
Reference in New Issue
Block a user