mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-29 14:47:21 +02:00
Epub ereader volume navigate setting fixes and disable when player is open
This commit is contained in:
@@ -56,7 +56,7 @@
|
|||||||
<!-- ereader settings modal -->
|
<!-- ereader settings modal -->
|
||||||
<modals-fullscreen-modal v-model="showSettingsModal" :theme="ereaderTheme" half-screen>
|
<modals-fullscreen-modal v-model="showSettingsModal" :theme="ereaderTheme" half-screen>
|
||||||
<div style="box-shadow: 0px -8px 8px #11111155">
|
<div style="box-shadow: 0px -8px 8px #11111155">
|
||||||
<div class="flex items-end justify-between h-20 px-4 pb-2 mb-6">
|
<div class="flex items-end justify-between h-14 px-4 pb-2 mb-6">
|
||||||
<h1 class="text-lg">{{ $strings.HeaderEreaderSettings }}</h1>
|
<h1 class="text-lg">{{ $strings.HeaderEreaderSettings }}</h1>
|
||||||
<button class="flex" @click="showSettingsModal = false">
|
<button class="flex" @click="showSettingsModal = false">
|
||||||
<span class="material-icons">close</span>
|
<span class="material-icons">close</span>
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<ui-range-input v-model="ereaderSettings.textStroke" :min="0" :max="300" :step="5" input-width="180px" @input="settingsUpdated" />
|
<ui-range-input v-model="ereaderSettings.textStroke" :min="0" :max="300" :step="5" input-width="180px" @input="settingsUpdated" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center mb-6">
|
||||||
<div class="w-32">
|
<div class="w-32">
|
||||||
<p class="text-base">{{ $strings.LabelLayout }}:</p>
|
<p class="text-base">{{ $strings.LabelLayout }}:</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -109,8 +109,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Capacitor } from '@capacitor/core'
|
import { Capacitor } from '@capacitor/core'
|
||||||
import { VolumeButtons } from '@capacitor-community/volume-buttons';
|
import { VolumeButtons } from '@capacitor-community/volume-buttons'
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -126,6 +125,7 @@ export default {
|
|||||||
showSettingsModal: false,
|
showSettingsModal: false,
|
||||||
comicHasMetadata: false,
|
comicHasMetadata: false,
|
||||||
chapters: [],
|
chapters: [],
|
||||||
|
isInittingWatchVolume: false,
|
||||||
ereaderSettings: {
|
ereaderSettings: {
|
||||||
theme: 'dark',
|
theme: 'dark',
|
||||||
fontScale: 100,
|
fontScale: 100,
|
||||||
@@ -150,6 +150,12 @@ export default {
|
|||||||
this.$showHideStatusBar(true)
|
this.$showHideStatusBar(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isPlayerOpen(newVal, oldVal) {
|
||||||
|
// Closed player
|
||||||
|
if (!newVal && oldVal) {
|
||||||
|
this.initWatchVolume()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -289,6 +295,8 @@ export default {
|
|||||||
settingsUpdated() {
|
settingsUpdated() {
|
||||||
this.$refs.readerComponent?.updateSettings?.(this.ereaderSettings)
|
this.$refs.readerComponent?.updateSettings?.(this.ereaderSettings)
|
||||||
localStorage.setItem('ereaderSettings', JSON.stringify(this.ereaderSettings))
|
localStorage.setItem('ereaderSettings', JSON.stringify(this.ereaderSettings))
|
||||||
|
|
||||||
|
this.initWatchVolume()
|
||||||
},
|
},
|
||||||
goToChapter(href) {
|
goToChapter(href) {
|
||||||
this.showTOCModal = false
|
this.showTOCModal = false
|
||||||
@@ -413,37 +421,46 @@ export default {
|
|||||||
console.error('Failed to load ereader settings', error)
|
console.error('Failed to load ereader settings', error)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async initWatchVolume() {
|
||||||
|
if (this.isInittingWatchVolume || !this.isEpub) return
|
||||||
|
this.isInittingWatchVolume = true
|
||||||
|
const isWatching = await VolumeButtons.isWatching()
|
||||||
|
|
||||||
|
if (this.ereaderSettings.navigateWithVolume !== 'none' && !this.isPlayerOpen) {
|
||||||
|
if (!isWatching.value) {
|
||||||
|
const options = {
|
||||||
|
disableSystemVolumeHandler: true,
|
||||||
|
suppressVolumeIndicator: true
|
||||||
|
}
|
||||||
|
await VolumeButtons.watchVolume(options, this.volumePressed)
|
||||||
|
}
|
||||||
|
} else if (isWatching.value) {
|
||||||
|
await VolumeButtons.clearWatch()
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isInittingWatchVolume = false
|
||||||
|
},
|
||||||
registerListeners() {
|
registerListeners() {
|
||||||
this.$eventBus.$on('close-ebook', this.closeEvt)
|
this.$eventBus.$on('close-ebook', this.closeEvt)
|
||||||
document.body.addEventListener('touchstart', this.touchstart)
|
document.body.addEventListener('touchstart', this.touchstart)
|
||||||
document.body.addEventListener('touchend', this.touchend)
|
document.body.addEventListener('touchend', this.touchend)
|
||||||
|
this.initWatchVolume()
|
||||||
if (!this.isMobi && this.ereaderSettings.navigateWithVolume != 'none'){
|
|
||||||
const options = {
|
|
||||||
disableSystemVolumeHandler: true,
|
|
||||||
suppressVolumeIndicator: true
|
|
||||||
}
|
|
||||||
VolumeButtons.watchVolume(options, this.volumePressed);
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
unregisterListeners() {
|
unregisterListeners() {
|
||||||
this.$eventBus.$on('close-ebook', this.closeEvt)
|
this.$eventBus.$on('close-ebook', this.closeEvt)
|
||||||
document.body.removeEventListener('touchstart', this.touchstart)
|
document.body.removeEventListener('touchstart', this.touchstart)
|
||||||
document.body.removeEventListener('touchend', this.touchend)
|
document.body.removeEventListener('touchend', this.touchend)
|
||||||
if (VolumeButtons.isWatching()) {
|
VolumeButtons.clearWatch()
|
||||||
VolumeButtons.clearWatch();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
volumePressed(e) {
|
volumePressed(e) {
|
||||||
if (this.ereaderSettings.navigateWithVolume == 'enabled'){
|
if (this.ereaderSettings.navigateWithVolume == 'enabled') {
|
||||||
if (e.direction == "up") {
|
if (e.direction == 'up') {
|
||||||
this.prev()
|
this.prev()
|
||||||
} else {
|
} else {
|
||||||
this.next()
|
this.next()
|
||||||
}
|
}
|
||||||
} else if (this.ereaderSettings.navigateWithVolume == 'mirrored') {
|
} else if (this.ereaderSettings.navigateWithVolume == 'mirrored') {
|
||||||
if (e.direction == "down") {
|
if (e.direction == 'down') {
|
||||||
this.prev()
|
this.prev()
|
||||||
} else {
|
} else {
|
||||||
this.next()
|
this.next()
|
||||||
|
|||||||
Reference in New Issue
Block a user