Move AbsAudioPlayer.setChapterTrack to AudioPlayer instead of localStore

This commit is contained in:
advplyr 2024-01-01 08:22:20 -06:00
parent 73d70dd480
commit 322cad5548
2 changed files with 9 additions and 8 deletions

View file

@ -695,8 +695,8 @@ export default {
this.updateTimestamp() this.updateTimestamp()
this.updateTrack() this.updateTrack()
this.updateReadyTrack() this.updateReadyTrack()
this.updateUseChapterTrack()
this.$localStore.setUseTotalTrack(this.useTotalTrack) this.$localStore.setUseTotalTrack(this.useTotalTrack)
this.$localStore.setUseChapterTrack(this.useChapterTrack)
} else if (action === 'total_track') { } else if (action === 'total_track') {
this.useTotalTrack = !this.useTotalTrack this.useTotalTrack = !this.useTotalTrack
this.useChapterTrack = !this.useTotalTrack || this.useChapterTrack this.useChapterTrack = !this.useTotalTrack || this.useChapterTrack
@ -704,13 +704,20 @@ export default {
this.updateTimestamp() this.updateTimestamp()
this.updateTrack() this.updateTrack()
this.updateReadyTrack() this.updateReadyTrack()
this.updateUseChapterTrack()
this.$localStore.setUseTotalTrack(this.useTotalTrack) this.$localStore.setUseTotalTrack(this.useTotalTrack)
this.$localStore.setUseChapterTrack(this.useChapterTrack)
} else if (action === 'close') { } else if (action === 'close') {
this.closePlayback() this.closePlayback()
} }
}) })
}, },
updateUseChapterTrack() {
this.$localStore.setUseChapterTrack(this.useChapterTrack)
// Chapter track in NowPlaying only supported on iOS for now
if (this.$platform === 'ios') {
AbsAudioPlayer.setChapterTrack({ enabled: this.useChapterTrack })
}
},
forceCloseDropdownMenu() { forceCloseDropdownMenu() {
if (this.$refs.dropdownMenu && this.$refs.dropdownMenu.closeMenu) { if (this.$refs.dropdownMenu && this.$refs.dropdownMenu.closeMenu) {
this.$refs.dropdownMenu.closeMenu() this.$refs.dropdownMenu.closeMenu()

View file

@ -1,7 +1,4 @@
import { Preferences } from '@capacitor/preferences' import { Preferences } from '@capacitor/preferences'
import { AbsAudioPlayer } from '@/plugins/capacitor'
import { Capacitor } from '@capacitor/core'
class LocalStorage { class LocalStorage {
constructor(vuexStore) { constructor(vuexStore) {
@ -48,9 +45,6 @@ class LocalStorage {
async setUseChapterTrack(useChapterTrack) { async setUseChapterTrack(useChapterTrack) {
try { try {
await Preferences.set({ key: 'useChapterTrack', value: useChapterTrack ? '1' : '0' }) await Preferences.set({ key: 'useChapterTrack', value: useChapterTrack ? '1' : '0' })
if (Capacitor.getPlatform() === 'ios') {
AbsAudioPlayer.setChapterTrack({ enabled: useChapterTrack })
}
} catch (error) { } catch (error) {
console.error('[LocalStorage] Failed to set use chapter track', error) console.error('[LocalStorage] Failed to set use chapter track', error)
} }