diff --git a/components/cards/LazyListBookCard.vue b/components/cards/LazyListBookCard.vue index fc3a1d38..7453f524 100644 --- a/components/cards/LazyListBookCard.vue +++ b/components/cards/LazyListBookCard.vue @@ -14,7 +14,7 @@
-
+

#{{ seriesSequence }} {{ displayTitle }}

@@ -29,6 +29,11 @@ {{ $getString('LabelNumEpisodes', [numEpisodes]) }}

+
+ +
download_done @@ -129,6 +134,9 @@ export default { libraryItemId() { return this._libraryItem.id }, + localLibraryItemId() { + return this.localLibraryItem?.id + }, series() { return this.mediaMetadata.series }, @@ -217,13 +225,23 @@ export default { return this.isMissing || this.isInvalid }, isStreaming() { - return this.store.getters['getlibraryItemIdStreaming'] === this.libraryItemId + return this.isPlaying && !this.store.getters['getIsCurrentSessionLocal'] + }, + isPlaying() { + if (this.localLibraryItemId && this.store.getters['getIsMediaStreaming'](this.localLibraryItemId)) return true + return this.store.getters['getIsMediaStreaming'](this.libraryItemId) + }, + playerIsPlaying() { + return this.store.state.playerIsPlaying && (this.isStreaming || this.isPlaying) + }, + isCasting() { + return this.store.state.isCasting }, showReadButton() { return !this.isSelectionMode && !this.showPlayButton && this.hasEbook }, showPlayButton() { - return !this.isSelectionMode && !this.isMissing && !this.isInvalid && this.numTracks && !this.isStreaming + return !this.isSelectionMode && !this.isMissing && !this.isInvalid && this.numTracks && !this.isPodcast }, showSmallEBookIcon() { return !this.isSelectionMode && this.hasEbook @@ -293,9 +311,30 @@ export default { this.selected = !this.selected this.$emit('select', this.libraryItem) }, - play() { - var eventBus = this.$eventBus || this.$nuxt.$eventBus - eventBus.$emit('play-item', { libraryItemId: this.libraryItemId }) + async play() { + const hapticsImpact = this.$hapticsImpact || this.$nuxt.$hapticsImpact + if (hapticsImpact) { + await hapticsImpact() + } + + const eventBus = this.$eventBus || this.$nuxt.$eventBus + + if (this.playerIsPlaying) { + eventBus.$emit('pause-item') + } else { + // Audiobook + let libraryItemId = this.libraryItemId + + // When casting use server library item + if (this.localLibraryItem && !this.isCasting) { + libraryItemId = this.localLibraryItem.id + } else if (this.hasLocal) { + libraryItemId = this.localLibraryItem.id + } + + this.store.commit('setPlayerIsStartingPlayback', libraryItemId) + eventBus.$emit('play-item', { libraryItemId, serverLibraryItemId: this.libraryItemId }) + } }, destroy() { // destroy the vue listeners, etc