Allow skipping to next item in queue

It's as simple as it sounds: When at the last chapter of a book (or podcast I guess?), the "Next Chapter" Button instead skips to the next item in the queue.
This commit is contained in:
Michael Finger 2024-08-05 12:37:16 +00:00
parent 8ff7b6b6e6
commit 5229f79805
4 changed files with 47 additions and 8 deletions

View file

@ -20,8 +20,8 @@
<span class="material-symbols text-2xl sm:text-3xl">forward_media</span> <span class="material-symbols text-2xl sm:text-3xl">forward_media</span>
</button> </button>
</ui-tooltip> </ui-tooltip>
<ui-tooltip direction="top" :text="$strings.ButtonNextChapter" class="ml-4 lg:ml-8"> <ui-tooltip direction="top" :text="nextLabel()" class="ml-4 lg:ml-8">
<button :aria-label="$strings.ButtonNextChapter" :disabled="!hasNextChapter" :class="hasNextChapter ? 'text-gray-300' : 'text-gray-500'" @mousedown.prevent @mouseup.prevent @click.stop="nextChapter"> <button :aria-label="nextLabel()" :disabled="!hasNextChapter && !hasNextAudiobook" :class="hasNextChapter || hasNextAudiobook ? 'text-gray-300' : 'text-gray-500'" @mousedown.prevent @mouseup.prevent @click.stop="nextChapter">
<span class="material-symbols text-2xl sm:text-3xl">last_page</span> <span class="material-symbols text-2xl sm:text-3xl">last_page</span>
</button> </button>
</ui-tooltip> </ui-tooltip>
@ -43,7 +43,8 @@ export default {
seekLoading: Boolean, seekLoading: Boolean,
playbackRate: Number, playbackRate: Number,
paused: Boolean, paused: Boolean,
hasNextChapter: Boolean hasNextChapter: Boolean,
hasNextAudiobook: Boolean
}, },
data() { data() {
return {} return {}
@ -72,8 +73,18 @@ export default {
this.$emit('prevChapter') this.$emit('prevChapter')
}, },
nextChapter() { nextChapter() {
if (!this.hasNextChapter) return if (this.hasNextChapter) {
this.$emit('nextChapter') this.$emit('nextChapter')
return
}
if (this.hasNextAudiobook) {
this.$emit('nextAudiobook')
return
}
},
nextLabel() {
if (this.hasNextChapter) return this.$strings.ButtonNextChapter
return this.$strings.ButtonNextAudiobook
}, },
jumpBackward() { jumpBackward() {
this.$emit('jumpBackward') this.$emit('jumpBackward')

View file

@ -43,7 +43,21 @@
</ui-tooltip> </ui-tooltip>
</div> </div>
<player-playback-controls :loading="loading" :seek-loading="seekLoading" :playback-rate.sync="playbackRate" :paused="paused" :has-next-chapter="hasNextChapter" @prevChapter="prevChapter" @nextChapter="nextChapter" @jumpForward="jumpForward" @jumpBackward="jumpBackward" @setPlaybackRate="setPlaybackRate" @playPause="playPause" /> <player-playback-controls
:loading="loading"
:seek-loading="seekLoading"
:playback-rate.sync="playbackRate"
:paused="paused"
:has-next-chapter="hasNextChapter"
:has-next-audiobook="hasNextAudiobook"
@prevChapter="prevChapter"
@nextChapter="nextChapter"
@nextAudiobook="nextAudiobook"
@jumpForward="jumpForward"
@jumpBackward="jumpBackward"
@setPlaybackRate="setPlaybackRate"
@playPause="playPause"
/>
</div> </div>
<player-track-bar ref="trackbar" :loading="loading" :chapters="chapters" :duration="duration" :current-chapter="currentChapter" :playback-rate="playbackRate" @seek="seek" /> <player-track-bar ref="trackbar" :loading="loading" :chapters="chapters" :duration="duration" :current-chapter="currentChapter" :playback-rate="playbackRate" @seek="seek" />
@ -166,6 +180,9 @@ export default {
if (!this.chapters.length) return false if (!this.chapters.length) return false
return this.currentChapterIndex < this.chapters.length - 1 return this.currentChapterIndex < this.chapters.length - 1
}, },
hasNextAudiobook() {
return this.playerQueueItems.length > 1
},
playerQueueItems() { playerQueueItems() {
return this.$store.state.playerQueueItems || [] return this.$store.state.playerQueueItems || []
}, },
@ -283,6 +300,15 @@ export default {
var nextChapter = this.chapters[this.currentChapterIndex + 1] var nextChapter = this.chapters[this.currentChapterIndex + 1]
this.seek(nextChapter.start) this.seek(nextChapter.start)
}, },
nextAudiobook() {
let nextBook = this.playerQueueItems[1]
this.$eventBus.$emit('play-item', {
libraryItemId: nextBook.libraryItemId,
episodeId: nextBook.episodeId || null,
queueItems: this.playerQueueItems
})
},
setStreamReady() { setStreamReady() {
if (this.$refs.trackbar) this.$refs.trackbar.setPercentageReady(1) if (this.$refs.trackbar) this.$refs.trackbar.setPercentageReady(1)
}, },

View file

@ -45,6 +45,7 @@
"ButtonMatchBooks": "Online Metadaten-Abgleich (alle Medien)", "ButtonMatchBooks": "Online Metadaten-Abgleich (alle Medien)",
"ButtonNevermind": "Abbrechen", "ButtonNevermind": "Abbrechen",
"ButtonNext": "Vor", "ButtonNext": "Vor",
"ButtonNextAudiobook": "Nächstes Buch",
"ButtonNextChapter": "Nächstes Kapitel", "ButtonNextChapter": "Nächstes Kapitel",
"ButtonOk": "Ok", "ButtonOk": "Ok",
"ButtonOpenFeed": "Feed öffnen", "ButtonOpenFeed": "Feed öffnen",

View file

@ -45,6 +45,7 @@
"ButtonMatchBooks": "Match Books", "ButtonMatchBooks": "Match Books",
"ButtonNevermind": "Nevermind", "ButtonNevermind": "Nevermind",
"ButtonNext": "Next", "ButtonNext": "Next",
"ButtonNextAudiobook": "Next Book",
"ButtonNextChapter": "Next Chapter", "ButtonNextChapter": "Next Chapter",
"ButtonOk": "Ok", "ButtonOk": "Ok",
"ButtonOpenFeed": "Open Feed", "ButtonOpenFeed": "Open Feed",