Fix: sync playstate when app resumes #1641
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Followup to #1640
Brief summary
Playstate is not syncronized when the app is opened which means the player is missing and status is not synced when main process stopped and resumed.
Which issue is fixed?
Could help with this issue #1516 or other related server sync issues.
Pull Request Type
Android
In-depth Description
Realized the playstate is not synced with UI when the application is resumed after being killed either in the app switcher by the user or in the background. This means the service tracking/syncronizing progress isn't updated either and the UI doesn't have an active player. With this change the playstate is synced when the app is resumed and the ui service is ready.
How have you tested this?
Running on phone and emulator. Play a book swipe to close audiobookshelf in recents. Open audiobookshelf and player opens with the correct book and play state. Without these changes the ui and services were un-aware of the current play state. Tested in multiple states closing and opening the app. Still testing with previous pr to make sure it solves android auto and syncing issues.
Update: tested throughout the day and not seeing any increased battery usage. Still working great and listening sessions are being recorded in server.
Screenshots
screen-20250723-181241.3.mp4