Add rewind on pause - #1
Closed
skorokithakis wants to merge 1 commit into
Closed
Conversation
Moves the position back when a book is continued, proportionally to how long that book was paused: amount * min(pause, 300s) / 300s. A momentary pause moves almost nothing, a pause of five minutes or more moves the full amount. The setting lives in Settings -> Playback -> Seek settings (on by default, 30s, 1-60s) and is part of the settings backup. It reuses the dormant RewindOnPauseTime domain class and drops the unused SeekTimeOption enum. The last active time is stored per book, so pausing book A and listening to book B does not reset A. A book with no stored time gets the full rewind. The map keeps the 100 newest books. The rewind is applied in one place, a forwarding player around the ExoPlayer that the media session is built on, so the seek happens before the audio starts and every source behaves the same: the app, the notification, media buttons, Android Auto, the widget, and the sleep timer. It fires only on a real playWhenReady false -> true change, so a repeated play command cannot rewind. The automatic resume after a short audio focus loss has no play command, so it is covered separately by the playback suppression reason; a buffering stall is excluded there.
Owner
Author
|
Superseded by GrakovNe#492, which targets upstream. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Moves the position back when a book is continued, proportionally to how long that book was paused:
So a momentary pause moves almost nothing, and a pause of five minutes or more moves the full amount.
The setting
"Rewind on pause" in Settings -> Playback -> Seek settings: a toggle and an amount (1-60s, presets 5/10/15/30/60), on by default with 30s. It is part of the settings backup, and the amount is clamped to 1-60 both on read and on import, so an edited backup cannot produce a strange rewind.
This puts the dormant
RewindOnPauseTimedomain class to use and removes theSeekTimeOptionenum, which nothing else referenced.Per book, not global
The last active time is stored per book (a
bookId -> epoch millismap, capped at the 100 newest books). Pausing book A and starting book B must not reset A's clock: the rewind models how much of that book the listener forgot. A book with no stored time gets the full rewind, because "no record" means the listener probably forgot more, not less.One choke point
The rewind is applied by a thin
ForwardingPlayeraround theExoPlayerthat theMediaLibrarySessionis built on. The seek therefore happens before the audio starts, so there is no audible jump, and every source behaves the same: the app, the notification, media buttons, Android Auto, the widget, the sleep timer, a book switch, and a resume after the process was killed.Two details in there:
playWhenReadyfalse -> true change, so a repeated play command during a session cannot rewind.Notes for review
C.TIME_UNSETfor chapters that ExoPlayer has not prepared yet, which would silently disable the rewind on the first play after opening the app.Tests
Unit tests for the proportional maths and the seek target (including crossing chapter starts and clamping at the start of the book), the preference storage and its cap, the handler (book switch, suppression resume, the
playWhenReadygate), the settings backup, and the view model../gradlew lintKotlin testpasses.