Fix:Android playback rate set on initial load #532

This commit is contained in:
advplyr 2023-03-01 17:47:07 -06:00
parent 5a9e30b08c
commit 2f34da4e99
2 changed files with 20 additions and 2 deletions

View file

@ -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()

View file

@ -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() {