mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-31 23:20:35 +02:00
Fix:Android playback rate set on initial load #532
This commit is contained in:
parent
5a9e30b08c
commit
2f34da4e99
2 changed files with 20 additions and 2 deletions
|
@ -450,7 +450,6 @@ export default {
|
|||
this.$emit('showSleepTimer')
|
||||
},
|
||||
async setPlaybackSpeed(speed) {
|
||||
await this.$hapticsImpact()
|
||||
console.log(`[AudioPlayer] Set Playback Rate: ${speed}`)
|
||||
this.currentPlaybackRate = speed
|
||||
this.updateTimestamp()
|
||||
|
|
|
@ -37,6 +37,7 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
shelves: [],
|
||||
isSettingsLoaded: false,
|
||||
isFirstNetworkConnection: true,
|
||||
lastServerFetch: 0,
|
||||
lastServerFetchLibraryId: null,
|
||||
|
@ -276,12 +277,25 @@ export default {
|
|||
|
||||
this.isLoading = false
|
||||
},
|
||||
openMediaPlayerWithMostRecentListening() {
|
||||
async waitForSettings() {
|
||||
// Wait up to 3 seconds
|
||||
for (let i = 0; i < 6; i++) {
|
||||
if (this.isSettingsLoaded) return true
|
||||
await new Promise((resolve) => setTimeout(resolve, 500))
|
||||
}
|
||||
return false
|
||||
},
|
||||
async openMediaPlayerWithMostRecentListening() {
|
||||
// If we don't already have a player open
|
||||
// Try opening the first book from continue-listening without playing it
|
||||
if (this.$store.state.playerLibraryItemId || !this.$store.state.isFirstAudioLoad) return
|
||||
this.$store.commit('setIsFirstAudioLoad', false) // Only run this once on app launch
|
||||
|
||||
// Wait for settings to load to prevent race condition when setting playback speed.
|
||||
if (!this.isSettingsLoaded) {
|
||||
await this.waitForSettings()
|
||||
}
|
||||
|
||||
const continueListeningShelf = this.shelves.find((cat) => cat.id === 'continue-listening')
|
||||
const mostRecentEntity = continueListeningShelf?.entities?.[0]
|
||||
if (mostRecentEntity) {
|
||||
|
@ -356,11 +370,16 @@ export default {
|
|||
}
|
||||
})
|
||||
},
|
||||
settingsUpdated() {
|
||||
this.isSettingsLoaded = true
|
||||
},
|
||||
initListeners() {
|
||||
this.$eventBus.$on('library-changed', this.libraryChanged)
|
||||
this.$eventBus.$on('user-settings', this.settingsUpdated)
|
||||
},
|
||||
removeListeners() {
|
||||
this.$eventBus.$off('library-changed', this.libraryChanged)
|
||||
this.$eventBus.$off('user-settings', this.settingsUpdated)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue