mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-03 09:34:51 +02:00
Merge pull request #1622 from advplyr/play_from_library_list_rows
Add play button to book library list view
This commit is contained in:
commit
80b565c23f
1 changed files with 45 additions and 6 deletions
|
@ -14,7 +14,7 @@
|
|||
<!-- No progress shown for collapsed series or podcasts in library -->
|
||||
<div v-if="!isPodcast && !collapsedSeries" class="absolute bottom-0 left-0 h-1 shadow-sm max-w-full z-10 rounded-b" :class="itemIsFinished ? 'bg-success' : 'bg-yellow-400'" :style="{ width: coverWidth * userProgressPercent + 'px' }"></div>
|
||||
</div>
|
||||
<div class="flex-grow px-2">
|
||||
<div class="flex-grow pl-2" :class="showPlayButton ? 'pr-12' : 'pr-2'">
|
||||
<p class="whitespace-normal line-clamp-2" :style="{ fontSize: 0.8 * sizeMultiplier + 'rem' }">
|
||||
<span v-if="seriesSequence">#{{ seriesSequence }} </span>{{ displayTitle }}
|
||||
</p>
|
||||
|
@ -29,6 +29,11 @@
|
|||
{{ $getString('LabelNumEpisodes', [numEpisodes]) }}
|
||||
</p>
|
||||
</div>
|
||||
<div v-if="showPlayButton" class="absolute top-0 bottom-0 right-0 h-full flex items-center justify-center z-20 pr-1">
|
||||
<button type="button" class="p-2 rounded-full bg-fg-muted/50" @click.stop.prevent="play">
|
||||
<span class="material-symbols text-2xl fill text-white">{{ playerIsPlaying ? 'pause' : 'play_arrow' }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="localLibraryItem || isLocal" class="absolute top-0 right-0 z-20" :style="{ top: 0.375 * sizeMultiplier + 'rem', right: 0.375 * sizeMultiplier + 'rem', padding: `${0.1 * sizeMultiplier}rem ${0.25 * sizeMultiplier}rem` }">
|
||||
<span class="material-symbols text-2xl text-success">download_done</span>
|
||||
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue