mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-12 22:41:29 +00:00
Merge 98a01b8b10 into 47ea6b5092
This commit is contained in:
commit
6dfed7fa3a
2 changed files with 15 additions and 9 deletions
|
|
@ -603,6 +603,12 @@ export default {
|
|||
})
|
||||
},
|
||||
playChapter(chapter) {
|
||||
// Pause any existing audiobook playback to prevent multiple streams
|
||||
if (this.$store.state.streamLibraryItem) {
|
||||
this.$eventBus.$emit('pause-item')
|
||||
}
|
||||
|
||||
console.log('$store.state.streamLibraryItem', this.$store.state)
|
||||
console.log('Play Chapter', chapter.id)
|
||||
if (this.selectedChapterId === chapter.id) {
|
||||
console.log('Chapter already playing', this.isLoadingChapter, this.isPlayingChapter)
|
||||
|
|
@ -652,15 +658,8 @@ export default {
|
|||
})
|
||||
audioEl.addEventListener('ended', () => {
|
||||
console.log('Audio ended')
|
||||
const nextTrack = this.tracks.find((t) => t.index === this.currentTrackIndex + 1)
|
||||
if (nextTrack) {
|
||||
console.log('Playing next track', nextTrack.index)
|
||||
this.currentTrackIndex = nextTrack.index
|
||||
this.playTrackAtTime(nextTrack, 0)
|
||||
} else {
|
||||
console.log('No next track')
|
||||
this.destroyAudioEl()
|
||||
}
|
||||
// stop at end of chapter
|
||||
this.destroyAudioEl()
|
||||
})
|
||||
this.audioEl = audioEl
|
||||
},
|
||||
|
|
@ -1006,11 +1005,13 @@ export default {
|
|||
this.initChapters()
|
||||
|
||||
this.$eventBus.$on(`${this.libraryItem.id}_updated`, this.libraryItemUpdated)
|
||||
this.$eventBus.$on('pause-chapter', this.destroyAudioEl)
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.destroyAudioEl()
|
||||
|
||||
this.$eventBus.$off(`${this.libraryItem.id}_updated`, this.libraryItemUpdated)
|
||||
this.$eventBus.$off('pause-chapter', this.destroyAudioEl)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -244,6 +244,11 @@ export default class LocalAudioPlayer extends EventEmitter {
|
|||
}
|
||||
|
||||
play() {
|
||||
// Emit pause-chapter event to stop any other chapter playing
|
||||
if (this.ctx.$eventBus) {
|
||||
this.ctx.$eventBus.$emit('pause-chapter')
|
||||
}
|
||||
|
||||
this.playWhenReady = true
|
||||
if (this.player) this.player.play()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue