From d89c97ba1aae41eff0e311d2dbfa6cde92464269 Mon Sep 17 00:00:00 2001 From: Lars Kiesow Date: Tue, 17 Jan 2023 00:54:17 +0100 Subject: [PATCH] Chapter and Total Track in Player This patch allows user to not only add a chapter track but also remove the total track. This means that you can have only the total track or only the chapter track. This patch does not allow user to have no track at all. Disabling one track will automatically enable the other one, if that one is already disabled. The reasoning behind this is that for long-ish audio books, users will not very often look at the overall progress. In fact, I find the progress bar mostly useful only for quickly seeking to a position when jumping back a few seconds is not sufficient. In the seldom occasion that I want the overall progress, I can easily get it from the book details page. --- components/app/AudioPlayer.vue | 17 ++++++++++++++++- plugins/localStore.js | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/components/app/AudioPlayer.vue b/components/app/AudioPlayer.vue index c2972b8d..baf6e254 100644 --- a/components/app/AudioPlayer.vue +++ b/components/app/AudioPlayer.vue @@ -15,7 +15,7 @@

{{ isDirectPlayMethod ? 'Direct' : isLocalPlayMethod ? 'Local' : 'Transcode' }}

-
+

{{ currentTimePretty }}

@@ -147,6 +147,7 @@ export default { touchStartTime: 0, touchEndY: 0, useChapterTrack: false, + useTotalTrack: true, lockUi: false, isLoading: false, touchTrackStart: false, @@ -180,6 +181,11 @@ export default { items.push( ...[ + { + text: 'Total Track', + value: 'total_track', + icon: this.useTotalTrack ? 'check_box' : 'check_box_outline_blank' + }, { text: 'Chapter Track', value: 'chapter_track', @@ -705,11 +711,20 @@ export default { this.$localStore.setPlayerLock(this.lockUi) } else if (action === 'chapter_track') { this.useChapterTrack = !this.useChapterTrack + this.useTotalTrack = !this.useChapterTrack || this.useTotalTrack this.updateTimestamp() this.updateTrack() this.updateReadyTrack() this.$localStore.setUseChapterTrack(this.useChapterTrack) + } else if (action === 'total_track') { + this.useTotalTrack = !this.useTotalTrack + this.useChapterTrack = !this.useTotalTrack || this.useChapterTrack + + this.updateTimestamp() + this.updateTrack() + this.updateReadyTrack() + this.$localStore.setUseTotalTrack(this.useTotalTrack) } else if (action === 'close') { this.closePlayback() } diff --git a/plugins/localStore.js b/plugins/localStore.js index f7119512..df92bc1d 100644 --- a/plugins/localStore.js +++ b/plugins/localStore.js @@ -60,6 +60,24 @@ class LocalStorage { } } + async setUseTotalTrack(useTotalTrack) { + try { + await Storage.set({ key: 'useTotalTrack', value: useTotalTrack ? '1' : '0' }) + } catch (error) { + console.error('[LocalStorage] Failed to set use total track', error) + } + } + + async getUseTotalTrack() { + try { + var obj = await Storage.get({ key: 'useTotalTrack' }) || {} + return obj.value === '1' + } catch (error) { + console.error('[LocalStorage] Failed to get use total track', error) + return false + } + } + async setPlayerLock(lock) { try { await Storage.set({ key: 'playerLock', value: lock ? '1' : '0' })