2022-12-03 15:20:27 -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="libraryItem" :to="`/item/${libraryItem.id}`" class="flex items-center w-full">
|
2022-12-03 15:20:27 -06:00
|
|
|
<div class="h-full relative" :style="{ width: '50px' }">
|
|
|
|
<covers-book-cover :library-item="libraryItem" :width="50" :book-cover-aspect-ratio="bookCoverAspectRatio" />
|
|
|
|
</div>
|
2023-05-20 14:22:53 -05:00
|
|
|
<div class="item-table-content h-full px-2 flex items-center">
|
2022-12-03 15:20:27 -06:00
|
|
|
<div class="max-w-full">
|
2023-06-09 17:05:29 -05:00
|
|
|
<p class="truncate block text-sm">{{ itemTitle }} <span v-if="localLibraryItem" class="material-icons text-success text-base align-text-bottom">download_done</span></p>
|
|
|
|
<p v-if="authorName" class="truncate block text-gray-300 text-xs">{{ authorName }}</p>
|
|
|
|
<p class="text-xxs text-gray-400">{{ itemDuration }}</p>
|
2022-12-03 15:20:27 -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-12-03 15:20:27 -06:00
|
|
|
</nuxt-link>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
playlistId: String,
|
|
|
|
item: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isProcessingReadUpdate: false,
|
|
|
|
processingRemove: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
libraryItem() {
|
|
|
|
return this.item.libraryItem || {}
|
|
|
|
},
|
2023-06-09 17:05:29 -05:00
|
|
|
localLibraryItem() {
|
|
|
|
return this.item.localLibraryItem
|
|
|
|
},
|
2022-12-03 15:20:27 -06:00
|
|
|
episode() {
|
|
|
|
return this.item.episode
|
|
|
|
},
|
|
|
|
episodeId() {
|
2023-06-09 17:05:29 -05:00
|
|
|
return this.episode?.id || null
|
|
|
|
},
|
|
|
|
localEpisode() {
|
|
|
|
return this.item.localEpisode
|
2022-12-03 15:20:27 -06:00
|
|
|
},
|
|
|
|
media() {
|
|
|
|
return this.libraryItem.media || {}
|
|
|
|
},
|
|
|
|
mediaMetadata() {
|
|
|
|
return this.media.metadata || {}
|
|
|
|
},
|
|
|
|
tracks() {
|
|
|
|
if (this.episode) return []
|
|
|
|
return this.media.tracks || []
|
|
|
|
},
|
|
|
|
itemTitle() {
|
|
|
|
if (this.episode) return this.episode.title
|
|
|
|
return this.mediaMetadata.title || ''
|
|
|
|
},
|
|
|
|
bookAuthors() {
|
|
|
|
if (this.episode) return []
|
|
|
|
return this.mediaMetadata.authors || []
|
|
|
|
},
|
|
|
|
bookAuthorName() {
|
|
|
|
return this.bookAuthors.map((au) => au.name).join(', ')
|
|
|
|
},
|
2023-06-09 17:05:29 -05:00
|
|
|
authorName() {
|
|
|
|
if (this.episode) return this.mediaMetadata.author
|
|
|
|
return this.bookAuthorName
|
|
|
|
},
|
2022-12-03 15:20:27 -06:00
|
|
|
itemDuration() {
|
|
|
|
if (this.episode) return this.$elapsedPretty(this.episode.duration)
|
|
|
|
return this.$elapsedPretty(this.media.duration)
|
|
|
|
},
|
|
|
|
isMissing() {
|
|
|
|
return this.libraryItem.isMissing
|
|
|
|
},
|
|
|
|
isInvalid() {
|
|
|
|
return this.libraryItem.isInvalid
|
|
|
|
},
|
|
|
|
bookCoverAspectRatio() {
|
|
|
|
return this.$store.getters['libraries/getBookCoverAspectRatio']
|
|
|
|
},
|
|
|
|
coverWidth() {
|
|
|
|
return 50
|
|
|
|
},
|
|
|
|
isMissing() {
|
|
|
|
return this.libraryItem.isMissing
|
|
|
|
},
|
|
|
|
isInvalid() {
|
|
|
|
return this.libraryItem.isInvalid
|
|
|
|
},
|
2023-05-20 14:22:53 -05:00
|
|
|
showPlayBtn() {
|
|
|
|
return !this.isMissing && !this.isInvalid && (this.tracks.length || this.episode)
|
|
|
|
},
|
2022-12-03 15:20:27 -06:00
|
|
|
isStreaming() {
|
2023-06-19 12:37:44 -05:00
|
|
|
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)
|
2022-12-03 15:20:27 -06:00
|
|
|
},
|
2023-05-20 14:22:53 -05:00
|
|
|
streamIsPlaying() {
|
|
|
|
return this.$store.state.playerIsPlaying && this.isStreaming
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async playClick() {
|
|
|
|
await this.$hapticsImpact()
|
|
|
|
if (this.streamIsPlaying) {
|
|
|
|
this.$eventBus.$emit('pause-item')
|
2023-06-09 17:05:29 -05:00
|
|
|
} else if (this.localLibraryItem) {
|
|
|
|
this.$eventBus.$emit('play-item', {
|
|
|
|
libraryItemId: this.localLibraryItem.id,
|
|
|
|
episodeId: this.localEpisode?.id,
|
|
|
|
serverLibraryItemId: this.libraryItem.id,
|
|
|
|
serverEpisodeId: this.episodeId
|
|
|
|
})
|
2023-05-20 14:22:53 -05:00
|
|
|
} else {
|
|
|
|
this.$eventBus.$emit('play-item', {
|
|
|
|
libraryItemId: this.libraryItem.id,
|
|
|
|
episodeId: this.episodeId
|
|
|
|
})
|
|
|
|
}
|
2022-12-03 15:20:27 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.item-table-content {
|
2023-05-20 14:22:53 -05:00
|
|
|
width: calc(100% - 82px);
|
|
|
|
max-width: calc(100% - 82px);
|
2022-12-03 15:20:27 -06:00
|
|
|
}
|
|
|
|
</style>
|