mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-05 18:54:39 +02:00
Add:Player queue for audiobooks #1077
This commit is contained in:
parent
3357ccfaf3
commit
78559520ab
12 changed files with 221 additions and 24 deletions
|
@ -122,13 +122,42 @@ export default {
|
|||
}
|
||||
},
|
||||
clickPlay() {
|
||||
var nextBookNotRead = this.playableBooks.find((pb) => {
|
||||
var prog = this.$store.getters['user/getUserMediaProgress'](pb.id)
|
||||
return !prog || !prog.isFinished
|
||||
const queueItems = []
|
||||
|
||||
// Collection queue will start at the first unfinished book
|
||||
// if all books are finished then entire collection is queued
|
||||
const itemsWithProgress = this.playableBooks.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
progress: this.$store.getters['user/getUserMediaProgress'](item.id)
|
||||
}
|
||||
})
|
||||
if (nextBookNotRead) {
|
||||
|
||||
const hasUnfinishedItems = itemsWithProgress.some((i) => !i.progress || !i.progress.isFinished)
|
||||
if (!hasUnfinishedItems) {
|
||||
console.warn('All items in collection are finished - starting at first item')
|
||||
}
|
||||
|
||||
for (let i = 0; i < itemsWithProgress.length; i++) {
|
||||
const libraryItem = itemsWithProgress[i]
|
||||
if (!hasUnfinishedItems || !libraryItem.progress || !libraryItem.progress.isFinished) {
|
||||
queueItems.push({
|
||||
libraryItemId: libraryItem.id,
|
||||
libraryId: libraryItem.libraryId,
|
||||
episodeId: null,
|
||||
title: libraryItem.media.metadata.title,
|
||||
subtitle: libraryItem.media.metadata.authors.map((au) => au.name).join(', '),
|
||||
caption: '',
|
||||
duration: libraryItem.media.duration || null,
|
||||
coverPath: libraryItem.media.coverPath || null
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (queueItems.length >= 0) {
|
||||
this.$eventBus.$emit('play-item', {
|
||||
libraryItemId: nextBookNotRead.id
|
||||
libraryItemId: queueItems[0].libraryItemId,
|
||||
queueItems
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue