diff --git a/components/tables/collection/BookTableRow.vue b/components/tables/collection/BookTableRow.vue
index 98331687..9d722f84 100644
--- a/components/tables/collection/BookTableRow.vue
+++ b/components/tables/collection/BookTableRow.vue
@@ -6,7 +6,7 @@
-
{{ bookTitle }}
+
{{ bookTitle }} download_done
{{ bookAuthor }}
{{ bookDuration }}
@@ -39,6 +39,9 @@ export default {
libraryItemId() {
return this.book.id
},
+ localLibraryItem() {
+ return this.book.localLibraryItem
+ },
media() {
return this.book.media || {}
},
@@ -73,18 +76,34 @@ export default {
showPlayBtn() {
return !this.isMissing && !this.isInvalid && this.tracks.length
},
- isStreaming() {
+ playerIsStartingPlayback() {
+ // Play has been pressed and waiting for native play response
+ return this.$store.state.playerIsStartingPlayback
+ },
+ isOpenInPlayer() {
+ if (this.localLibraryItem && this.$store.getters['getIsMediaStreaming'](this.localLibraryItem.id)) return true
return this.$store.getters['getIsMediaStreaming'](this.libraryItemId)
},
streamIsPlaying() {
- return this.$store.state.playerIsPlaying && this.isStreaming
+ return this.$store.state.playerIsPlaying && this.isOpenInPlayer
}
},
methods: {
async playClick() {
+ if (this.playerIsStartingPlayback) return
await this.$hapticsImpact()
+
if (this.streamIsPlaying) {
this.$eventBus.$emit('pause-item')
+ return
+ }
+
+ this.$store.commit('setPlayerIsStartingPlayback', this.libraryItemId)
+ if (this.localLibraryItem) {
+ this.$eventBus.$emit('play-item', {
+ libraryItemId: this.localLibraryItem.id,
+ serverLibraryItemId: this.libraryItemId
+ })
} else {
this.$eventBus.$emit('play-item', {
libraryItemId: this.libraryItemId
diff --git a/components/tables/playlist/ItemTableRow.vue b/components/tables/playlist/ItemTableRow.vue
index b3e73916..1d5663f0 100644
--- a/components/tables/playlist/ItemTableRow.vue
+++ b/components/tables/playlist/ItemTableRow.vue
@@ -113,12 +113,12 @@ export default {
showPlayBtn() {
return !this.isMissing && !this.isInvalid && (this.tracks.length || this.episode)
},
- isStreaming() {
+ isOpenInPlayer() {
if (this.localLibraryItem && this.localEpisode && this.$store.getters['getIsMediaStreaming'](this.localLibraryItem.id, this.localEpisode.id)) return true
return this.$store.getters['getIsMediaStreaming'](this.libraryItem.id, this.episodeId)
},
streamIsPlaying() {
- return this.$store.state.playerIsPlaying && this.isStreaming
+ return this.$store.state.playerIsPlaying && this.isOpenInPlayer
},
playerIsStartingPlayback() {
// Play has been pressed and waiting for native play response
diff --git a/pages/collection/_id.vue b/pages/collection/_id.vue
index fe9b0c2b..964faa19 100644
--- a/pages/collection/_id.vue
+++ b/pages/collection/_id.vue
@@ -12,9 +12,9 @@
{{ collectionName }}
-
- play_arrow
- {{ streaming ? $strings.ButtonPlaying : $strings.ButtonPlay }}
+
+ {{ playerIsPlaying ? 'pause' : 'play_arrow' }}
+ {{ playerIsPlaying ? $strings.ButtonPause : $strings.ButtonPlay }}
@@ -47,6 +47,18 @@ export default {
return redirect('/bookshelf')
}
+ // Lookup matching local items and attach to collection items
+ if (collection.books.length) {
+ const localLibraryItems = (await app.$db.getLocalLibraryItems('book')) || []
+ if (localLibraryItems.length) {
+ collection.books.forEach((collectionItem) => {
+ const matchingLocalLibraryItem = localLibraryItems.find((lli) => lli.libraryItemId === collectionItem.id)
+ if (!matchingLocalLibraryItem) return
+ collectionItem.localLibraryItem = matchingLocalLibraryItem
+ })
+ }
+ }
+
return {
collection
}
@@ -70,13 +82,19 @@ export default {
description() {
return this.collection.description || ''
},
- playableBooks() {
+ playableItems() {
return this.bookItems.filter((book) => {
return !book.isMissing && !book.isInvalid && book.media.tracks.length
})
},
- streaming() {
- return !!this.playableBooks.find((b) => this.$store.getters['getIsMediaStreaming'](b.id))
+ playerIsPlaying() {
+ return this.$store.state.playerIsPlaying && this.isOpenInPlayer
+ },
+ isOpenInPlayer() {
+ return !!this.playableItems.find((i) => {
+ if (i.localLibraryItem && this.$store.getters['getIsMediaStreaming'](i.localLibraryItem.id)) return true
+ return this.$store.getters['getIsMediaStreaming'](i.id)
+ })
},
playerIsStartingPlayback() {
// Play has been pressed and waiting for native play response
@@ -88,21 +106,34 @@ export default {
return mediaId === this.mediaIdStartingPlayback
},
showPlayButton() {
- return this.playableBooks.length
+ return this.playableItems.length
}
},
methods: {
- clickPlay() {
+ async playClick() {
if (this.playerIsStartingPlayback) return
+ await this.$hapticsImpact()
- var nextBookNotRead = this.playableBooks.find((pb) => {
- var prog = this.$store.getters['user/getUserMediaProgress'](pb.id)
+ if (this.playerIsPlaying) {
+ this.$eventBus.$emit('pause-item')
+ } else {
+ this.playNextItem()
+ }
+ },
+ playNextItem() {
+ const nextBookNotRead = this.playableItems.find((pb) => {
+ const prog = this.$store.getters['user/getUserMediaProgress'](pb.id)
return !prog?.isFinished
})
if (nextBookNotRead) {
this.mediaIdStartingPlayback = nextBookNotRead.id
this.$store.commit('setPlayerIsStartingPlayback', nextBookNotRead.id)
- this.$eventBus.$emit('play-item', { libraryItemId: nextBookNotRead.id })
+
+ if (nextBookNotRead.localLibraryItem) {
+ this.$eventBus.$emit('play-item', { libraryItemId: nextBookNotRead.localLibraryItem.id, serverLibraryItemId: nextBookNotRead.id })
+ } else {
+ this.$eventBus.$emit('play-item', { libraryItemId: nextBookNotRead.id })
+ }
}
}
},
diff --git a/pages/playlist/_id.vue b/pages/playlist/_id.vue
index e56f083b..25096407 100644
--- a/pages/playlist/_id.vue
+++ b/pages/playlist/_id.vue
@@ -10,9 +10,9 @@
{{ playlistName }}