2021-11-14 19:59:34 -06:00
|
|
|
<template>
|
|
|
|
<div class="w-full px-2 py-2 overflow-hidden relative">
|
2023-05-20 14:22:53 -05:00
|
|
|
<nuxt-link v-if="book" :to="`/item/${book.id}`" class="flex items-center w-full">
|
2021-12-05 18:31:47 -06:00
|
|
|
<div class="h-full relative" :style="{ width: bookWidth + 'px' }">
|
2022-04-08 19:05:32 -05:00
|
|
|
<covers-book-cover :library-item="book" :width="bookWidth" :book-cover-aspect-ratio="bookCoverAspectRatio" />
|
2021-11-14 19:59:34 -06:00
|
|
|
</div>
|
2023-05-20 14:22:53 -05:00
|
|
|
<div class="book-table-content h-full px-2 flex items-center">
|
2022-07-04 14:59:56 -05:00
|
|
|
<div class="max-w-full">
|
2022-08-27 15:54:13 -05:00
|
|
|
<p class="truncate block text-sm">{{ bookTitle }}</p>
|
2022-04-08 19:05:32 -05:00
|
|
|
<p class="truncate block text-gray-400 text-xs">{{ bookAuthor }}</p>
|
2022-07-04 14:59:56 -05:00
|
|
|
<p class="text-xxs text-gray-500">{{ bookDuration }}</p>
|
2021-11-14 19:59:34 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-05-20 14:22:53 -05:00
|
|
|
<div class="w-8 min-w-8 flex justify-center">
|
|
|
|
<button v-if="showPlayBtn" class="w-8 h-8 rounded-full border border-white border-opacity-20 flex items-center justify-center" @click.stop.prevent="playClick">
|
|
|
|
<span class="material-icons" :class="streamIsPlaying ? '' : 'text-success'">{{ streamIsPlaying ? 'pause' : 'play_arrow' }}</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
2022-08-27 15:54:13 -05:00
|
|
|
</nuxt-link>
|
2021-11-14 19:59:34 -06:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
collectionId: String,
|
|
|
|
book: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isProcessingReadUpdate: false,
|
|
|
|
processingRemove: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2023-05-20 14:22:53 -05:00
|
|
|
libraryItemId() {
|
|
|
|
return this.book.id
|
|
|
|
},
|
2022-04-08 19:05:32 -05:00
|
|
|
media() {
|
|
|
|
return this.book.media || {}
|
2021-12-05 18:31:47 -06:00
|
|
|
},
|
2022-04-08 19:05:32 -05:00
|
|
|
mediaMetadata() {
|
|
|
|
return this.media.metadata || {}
|
2021-12-05 18:31:47 -06:00
|
|
|
},
|
2022-04-08 19:05:32 -05:00
|
|
|
tracks() {
|
|
|
|
return this.media.tracks || []
|
2021-11-14 19:59:34 -06:00
|
|
|
},
|
|
|
|
bookTitle() {
|
2022-04-08 19:05:32 -05:00
|
|
|
return this.mediaMetadata.title || ''
|
2021-11-14 19:59:34 -06:00
|
|
|
},
|
|
|
|
bookAuthor() {
|
2022-04-08 19:05:32 -05:00
|
|
|
return this.mediaMetadata.authorName || ''
|
2021-11-14 19:59:34 -06:00
|
|
|
},
|
|
|
|
bookDuration() {
|
2022-07-04 14:59:56 -05:00
|
|
|
return this.$elapsedPretty(this.media.duration)
|
2022-04-08 19:05:32 -05:00
|
|
|
},
|
|
|
|
bookCoverAspectRatio() {
|
2022-10-22 08:59:10 -05:00
|
|
|
return this.$store.getters['libraries/getBookCoverAspectRatio']
|
2022-04-08 19:05:32 -05:00
|
|
|
},
|
|
|
|
bookWidth() {
|
2022-07-04 14:59:56 -05:00
|
|
|
if (this.bookCoverAspectRatio === 1) return 50
|
2022-04-08 19:05:32 -05:00
|
|
|
return 50
|
2021-11-14 19:59:34 -06:00
|
|
|
},
|
|
|
|
isMissing() {
|
|
|
|
return this.book.isMissing
|
|
|
|
},
|
2023-05-20 14:22:53 -05:00
|
|
|
isInvalid() {
|
|
|
|
return this.book.isInvalid
|
2021-11-14 19:59:34 -06:00
|
|
|
},
|
2023-05-20 14:22:53 -05:00
|
|
|
showPlayBtn() {
|
|
|
|
return !this.isMissing && !this.isInvalid && this.tracks.length
|
2021-11-14 19:59:34 -06:00
|
|
|
},
|
|
|
|
isStreaming() {
|
2023-06-19 12:37:44 -05:00
|
|
|
return this.$store.getters['getIsMediaStreaming'](this.libraryItemId)
|
2021-11-14 19:59:34 -06:00
|
|
|
},
|
2023-05-20 14:22:53 -05:00
|
|
|
streamIsPlaying() {
|
|
|
|
return this.$store.state.playerIsPlaying && this.isStreaming
|
2021-11-14 19:59:34 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2023-05-20 14:22:53 -05:00
|
|
|
async playClick() {
|
|
|
|
await this.$hapticsImpact()
|
|
|
|
if (this.streamIsPlaying) {
|
|
|
|
this.$eventBus.$emit('pause-item')
|
|
|
|
} else {
|
|
|
|
this.$eventBus.$emit('play-item', {
|
|
|
|
libraryItemId: this.libraryItemId
|
|
|
|
})
|
|
|
|
}
|
2021-11-14 19:59:34 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
2022-07-04 14:59:56 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.book-table-content {
|
2023-05-20 14:22:53 -05:00
|
|
|
width: calc(100% - 82px);
|
|
|
|
max-width: calc(100% - 82px);
|
2022-07-04 14:59:56 -05:00
|
|
|
}
|
|
|
|
</style>
|