@@ -93,7 +93,11 @@ import MyNativeAudio from '@/plugins/my-native-audio'
export default {
props: {
playing: Boolean,
- audiobook: {
+ libraryItem: {
+ type: Object,
+ default: () => {}
+ },
+ mediaEntity: {
type: Object,
default: () => {}
},
@@ -105,7 +109,6 @@ export default {
type: Array,
default: () => []
},
- loading: Boolean,
sleepTimerRunning: Boolean,
sleepTimeRemaining: Number
},
@@ -140,7 +143,8 @@ export default {
listenTimeInterval: null,
listeningTimeSinceLastUpdate: 0,
totalListeningTimeInSession: 0,
- useChapterTrack: false
+ useChapterTrack: false,
+ isLoading: true
}
},
computed: {
@@ -175,17 +179,20 @@ export default {
}
return this.showFullscreen ? 200 : 60
},
- book() {
- return this.audiobook.book || {}
+ media() {
+ return this.libraryItem.media || {}
+ },
+ mediaMetadata() {
+ return this.media.metadata || {}
},
title() {
- return this.book.title
+ return this.mediaMetadata.title
},
- authorFL() {
- return this.book.authorFL
+ authorName() {
+ return this.mediaMetadata.authorName
},
chapters() {
- return (this.audiobook ? this.audiobook.chapters || [] : []).map((chapter) => {
+ return (this.mediaEntity ? this.mediaEntity.chapters || [] : []).map((chapter) => {
var chap = { ...chapter }
chap.start = Number(chap.start)
chap.end = Number(chap.end)
@@ -193,7 +200,7 @@ export default {
})
},
currentChapter() {
- if (!this.audiobook || !this.chapters.length) return null
+ if (!this.mediaEntity || !this.chapters.length) return null
return this.chapters.find((ch) => Number(Number(ch.start).toFixed(2)) <= this.currentTime && Number(Number(ch.end).toFixed(2)) > this.currentTime)
},
nextChapter() {
@@ -329,12 +336,12 @@ export default {
this.forceCloseDropdownMenu()
},
jumpNextChapter() {
- if (this.loading) return
+ if (this.isLoading) return
if (!this.nextChapter) return
this.seek(this.nextChapter.start)
},
jumpChapterStart() {
- if (this.loading) return
+ if (this.isLoading) return
if (!this.currentChapter) {
return this.restart()
}
@@ -362,11 +369,11 @@ export default {
this.seek(0)
},
backward10() {
- if (this.loading) return
+ if (this.isLoading) return
MyNativeAudio.seekBackward({ amount: '10000' })
},
forward10() {
- if (this.loading) return
+ if (this.isLoading) return
MyNativeAudio.seekForward({ amount: '10000' })
},
setStreamReady() {
@@ -461,7 +468,7 @@ export default {
}
},
seek(time) {
- if (this.loading) return
+ if (this.isLoading) return
if (this.seekLoading) {
console.error('Already seek loading', this.seekedTime)
return
@@ -482,7 +489,7 @@ export default {
}
},
clickTrack(e) {
- if (this.loading) return
+ if (this.isLoading) return
if (!this.showFullscreen) {
// Track not clickable on mini-player
return
@@ -504,7 +511,7 @@ export default {
this.seek(time)
},
playPauseClick() {
- if (this.loading) return
+ if (this.isLoading) return
if (this.isPaused) {
console.log('playPause PLAY')
this.play()
@@ -641,6 +648,7 @@ export default {
MyNativeAudio.terminateStream()
},
onPlayingUpdate(data) {
+ console.log('onPlayingUpdate', JSON.stringify(data))
this.isPaused = !data.value
if (!this.isPaused) {
this.startPlayInterval()
@@ -649,6 +657,9 @@ export default {
}
},
onMetadata(data) {
+ console.log('onMetadata', JSON.stringify(data))
+ this.isLoading = false
+
this.totalDuration = Number((data.duration / 1000).toFixed(2))
this.$emit('setTotalDuration', this.totalDuration)
this.currentTime = Number((data.currentTime / 1000).toFixed(2))
diff --git a/components/app/AudioPlayerContainer.vue b/components/app/AudioPlayerContainer.vue
index f4f0565c..6dac10c1 100644
--- a/components/app/AudioPlayerContainer.vue
+++ b/components/app/AudioPlayerContainer.vue
@@ -1,12 +1,12 @@
-
+
{
- console.log('TEST library item play response', JSON.stringify(data))
- }).catch((error) => {
- console.error('TEST failed', error)
- })
+ MyNativeAudio.prepareLibraryItem({ libraryItemId, playWhenReady: true })
+ .then((data) => {
+ console.log('TEST library item play response', JSON.stringify(data))
+ var mediaEntity = data.mediaEntity
+ this.$store.commit('globals/setMediaEntityPlaying', mediaEntity)
+ })
+ .catch((error) => {
+ console.error('TEST failed', error)
+ })
}
},
mounted() {
diff --git a/components/bookshelf/Shelf.vue b/components/bookshelf/Shelf.vue
index 2cd57b20..8ef31151 100644
--- a/components/bookshelf/Shelf.vue
+++ b/components/bookshelf/Shelf.vue
@@ -2,7 +2,7 @@
-
+
diff --git a/components/cards/LazyBookCard.vue b/components/cards/LazyBookCard.vue
index 68b525d9..e34f187a 100644
--- a/components/cards/LazyBookCard.vue
+++ b/components/cards/LazyBookCard.vue
@@ -52,8 +52,6 @@