mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-09-01 07:30:00 +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')
|
this.$emit('showSleepTimer')
|
||||||
},
|
},
|
||||||
async setPlaybackSpeed(speed) {
|
async setPlaybackSpeed(speed) {
|
||||||
await this.$hapticsImpact()
|
|
||||||
console.log(`[AudioPlayer] Set Playback Rate: ${speed}`)
|
console.log(`[AudioPlayer] Set Playback Rate: ${speed}`)
|
||||||
this.currentPlaybackRate = speed
|
this.currentPlaybackRate = speed
|
||||||
this.updateTimestamp()
|
this.updateTimestamp()
|
||||||
|
|
|
@ -37,6 +37,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
shelves: [],
|
shelves: [],
|
||||||
|
isSettingsLoaded: false,
|
||||||
isFirstNetworkConnection: true,
|
isFirstNetworkConnection: true,
|
||||||
lastServerFetch: 0,
|
lastServerFetch: 0,
|
||||||
lastServerFetchLibraryId: null,
|
lastServerFetchLibraryId: null,
|
||||||
|
@ -276,12 +277,25 @@ export default {
|
||||||
|
|
||||||
this.isLoading = false
|
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
|
// If we don't already have a player open
|
||||||
// Try opening the first book from continue-listening without playing it
|
// Try opening the first book from continue-listening without playing it
|
||||||
if (this.$store.state.playerLibraryItemId || !this.$store.state.isFirstAudioLoad) return
|
if (this.$store.state.playerLibraryItemId || !this.$store.state.isFirstAudioLoad) return
|
||||||
this.$store.commit('setIsFirstAudioLoad', false) // Only run this once on app launch
|
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 continueListeningShelf = this.shelves.find((cat) => cat.id === 'continue-listening')
|
||||||
const mostRecentEntity = continueListeningShelf?.entities?.[0]
|
const mostRecentEntity = continueListeningShelf?.entities?.[0]
|
||||||
if (mostRecentEntity) {
|
if (mostRecentEntity) {
|
||||||
|
@ -356,11 +370,16 @@ export default {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
settingsUpdated() {
|
||||||
|
this.isSettingsLoaded = true
|
||||||
|
},
|
||||||
initListeners() {
|
initListeners() {
|
||||||
this.$eventBus.$on('library-changed', this.libraryChanged)
|
this.$eventBus.$on('library-changed', this.libraryChanged)
|
||||||
|
this.$eventBus.$on('user-settings', this.settingsUpdated)
|
||||||
},
|
},
|
||||||
removeListeners() {
|
removeListeners() {
|
||||||
this.$eventBus.$off('library-changed', this.libraryChanged)
|
this.$eventBus.$off('library-changed', this.libraryChanged)
|
||||||
|
this.$eventBus.$off('user-settings', this.settingsUpdated)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue