diff --git a/components/app/AudioPlayer.vue b/components/app/AudioPlayer.vue index 20ae55ae..4feb98b3 100644 --- a/components/app/AudioPlayer.vue +++ b/components/app/AudioPlayer.vue @@ -64,23 +64,24 @@
- first_page - {{ jumpBackwardsIcon }} + first_page + {{ jumpBackwardsIcon }}
{{ seekLoading ? 'autorenew' : !isPlaying ? 'play_arrow' : 'pause' }}
- {{ jumpForwardIcon }} - last_page + {{ jumpForwardIcon }} + last_page
-
+
+

0:00

@@ -95,10 +96,18 @@ + @@ -147,6 +156,7 @@ export default { touchStartTime: 0, touchEndY: 0, useChapterTrack: false, + lockUi: false, isLoading: false, touchTrackStart: false, dragPercent: 0, @@ -162,17 +172,24 @@ export default { }, computed: { menuItems() { - var items = [] - items.push({ - text: 'Chapter Track', - value: 'chapter_track', - icon: this.useChapterTrack ? 'check_box' : 'check_box_outline_blank' - }) - items.push({ - text: 'Close Player', - value: 'close', - icon: 'close' - }) + var items = [ + { + text: 'Chapter Track', + value: 'chapter_track', + icon: this.useChapterTrack ? 'check_box' : 'check_box_outline_blank' + }, + { + text: 'Lock/Unlock', + value: 'lock', + icon: this.lockUi ? 'lock' : 'lock_open' + }, + { + text: 'Close Player', + value: 'close', + icon: 'close' + } + ] + return items }, jumpForwardIcon() { @@ -319,7 +336,7 @@ export default { } }, touchstartTrack(e) { - if (!e || !e.touches || !this.$refs.track || !this.showFullscreen) return + if (!e || !e.touches || !this.$refs.track || !this.showFullscreen || this.lockUi) return this.touchTrackStart = true }, selectChapter(chapter) { @@ -469,6 +486,10 @@ export default { this.$refs.playedTrack.style.width = ptWidth + 'px' this.$refs.bufferedTrack.style.width = Math.round(bufferedPercent * this.trackWidth) + 'px' + if (this.$refs.trackCursor) { + this.$refs.trackCursor.style.left = ptWidth - 8 + 'px' + } + if (this.useChapterTrack) { if (this.$refs.totalPlayedTrack) this.$refs.totalPlayedTrack.style.width = Math.round(totalPercentDone * this.trackWidth) + 'px' if (this.$refs.totalBufferedTrack) this.$refs.totalBufferedTrack.style.width = Math.round(totalBufferedPercent * this.trackWidth) + 'px' @@ -496,7 +517,7 @@ export default { } }, clickTrack(e) { - if (this.isLoading) return + if (this.isLoading || this.lockUi) return if (!this.showFullscreen) { // Track not clickable on mini-player return @@ -622,7 +643,10 @@ export default { }, clickMenuAction(action) { this.showMoreMenuDialog = false - if (action === 'chapter_track') { + if (action === 'lock') { + this.lockUi = !this.lockUi + this.$localStore.setPlayerLock(this.lockUi) + } else if (action === 'chapter_track') { this.useChapterTrack = !this.useChapterTrack this.$nextTick(() => { @@ -715,6 +739,7 @@ export default { }, async init() { this.useChapterTrack = await this.$localStore.getUseChapterTrack() + this.lockUi = await this.$localStore.getPlayerLock() this.onPlaybackSessionListener = AbsAudioPlayer.addListener('onPlaybackSession', this.onPlaybackSession) this.onPlaybackClosedListener = AbsAudioPlayer.addListener('onPlaybackClosed', this.onPlaybackClosed) diff --git a/plugins/localStore.js b/plugins/localStore.js index b88e3411..b0ee0094 100644 --- a/plugins/localStore.js +++ b/plugins/localStore.js @@ -60,6 +60,24 @@ class LocalStorage { } } + async setPlayerLock(lock) { + try { + await Storage.set({ key: 'playerLock', value: lock ? '1' : '0' }) + } catch (error) { + console.error('[LocalStorage] Failed to set player lock', error) + } + } + + async getPlayerLock() { + try { + var obj = await Storage.get({ key: 'playerLock' }) || {} + return obj.value === '1' + } catch (error) { + console.error('[LocalStorage] Failed to get player lock', error) + return false + } + } + async setBookshelfListView(useIt) { try { await Storage.set({ key: 'bookshelfListView', value: useIt ? '1' : '0' })