Repository navigation
feat: step one narration cue with next/previous in media-overlay books - #333
Open
ddfreiling wants to merge 7 commits into
Open
ddfreiling wants to merge 7 commits into
ddfreiling wants to merge 7 commits into
Conversation
next() and previous() now move one cue (sentence or panel) in publications with sync narration or guided navigation, on iOS, Android and web. The cue list is flat across the publication, so a step crosses resource boundaries. - previous() restarts the current cue when more than 2 s into it, otherwise goes to the previous cue; next() on the last cue is a no-op. - Play state is kept; the view follows the target cue while paused. - A step re-enables narration sync from manual mode without flashing the old cue first. - A seek landing up to 0.1 s before a cue start counts as that cue. TTS (one utterance) and plain audiobooks are unchanged. Lock-screen and remote next/previous keep the seek interval, and audioSeekBy remains the way to skip by time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fixes for media-overlay next/previous: - iOS: chain cue steps. Overlapping steps ran goBounded concurrently, so the first to finish cleared _isNavigating while the second go(to:) was still running, and both read the same position. A locator without a time fragment now steps from 0, as on Android, instead of doing nothing. - Android: guard cue steps with a mutex, since method calls run in parallel coroutines, and read the position from playback state, which is current as soon as the previous seek settles. - Web: while playing, step from the media clock; the polled locator can still name the previous cue. Tests: Jest for two quick steps and the lagging locator; integration tests for a rapid double next(), stepping while playing, and a settle delay before the single sync-emission assert. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * origin/main: ci(android): retry the suite when adb install hangs on API 24
Collaborator
|
Findings from kb-review: Should fix
Nice to have
|
Cue steps were serialised against each other only. goToLocator and goToProgression also reach goBounded, so a seek during a step could run two go(to:) calls at once, and the first to finish cleared _isNavigating while the other was still in flight. goBounded now runs through one queue on the navigator, and a cue step runs its read, seek and view resync inside it. iOS also stepped from audioLocator, which only moves on the delegate's periodic tick. It now reads playbackInfo, as Android and web read their live position. On Android, skipToCue returns false when the target cue's audio is not in the reading order, instead of reporting a step that goToLocator silently dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The navigator's current-locator flow is throttled and deduplicated. After goToLocator, which writes its target into the timebased state, a step back to a position the flow already reported (e.g. "previous" restarting the cue the player sat on) produced no new emission. The state then kept the goToLocator target instead of the cue. skipToCue now returns the cue's locator, and the step writes it to the state the same way goToLocator does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved cue-step sequencing and session-isolation bugs can repeat cues, desynchronize narration and visuals, or apply queued steps to a different book.
8 open issues
Await manual-mode catch-up under the cue-step mutex · New Wait for seek completion before releasing cue-step mutex · New Await visual resync within the serialized cue step · New Bind queued cue steps to their originating audio session · New Keep notification controls on the interval-seek path · New Use live playback position when stepping while paused · New Abort cue-step follow-up when the audio seek fails · New Avoid duplicate sync notifications during cross-page seeks · New
What changed in this PR
This PR adds cue-by-cue narration stepping to media-overlay playback across iOS, Android, and web, without changing the public Dart API.
Changes:
- Adds publication-wide cue selection, including chapter transitions and the two-second restart rule for
previous(). - Introduces queued stepping and narration-sync handling intended to preserve playback state.
- Adds unit and integration coverage, API documentation, and a changelog fragment.
| File | Description |
|---|---|
| flutter_readium/web/src/ReadiumReader.ts | Adds queued cue stepping and sync handling. |
| flutter_readium/web/src/navigators/FlutterDivinaNavigator.ts | Exposes comic manual-override state. |
| flutter_readium/web/src/mediaoverlay/syncNarration.ts | Adds cue-target selection. |
| flutter_readium/web/src/__tests__/syncNarration.test.ts | Tests cue boundaries and selection rules. |
| flutter_readium/web/src/__tests__/ReadiumReaderCueStep.test.ts | Tests stepping, playback state, and synchronization. |
| flutter_readium/lib/flutter_readium.dart | Documents public next/previous behavior. |
| flutter_readium/ios/flutter_readium/Sources/flutter_readium/reader/EPUBReaderView+Navigation.swift | Adds target-specific narration resync. |
| flutter_readium/ios/flutter_readium/Sources/flutter_readium/navigator/FlutterMediaOverlayNavigator.swift | Implements cue stepping and cue reporting. |
| flutter_readium/ios/flutter_readium/Sources/flutter_readium/navigator/FlutterAudioNavigator.swift | Adds navigation serialization and live playhead lookup. |
| flutter_readium/ios/flutter_readium/Sources/flutter_readium/model/FlutterMediaOverlay.swift | Adds publication-wide cue selection. |
| flutter_readium/ios/flutter_readium/Sources/flutter_readium/FlutterReadiumPlugin.swift | Routes media-overlay commands to cue stepping. |
| flutter_readium/example/ios/RunnerTests/FlutterMediaOverlayTests.swift | Tests iOS cue-selection rules. |
| flutter_readium/example/integration_test/groups/timebased_playback_test.dart | Adds native playback and synchronization scenarios. |
| flutter_readium/changelog.d/+media-overlay-cue-step.changed.md | Describes the consumer-visible behavior change. |
| flutter_readium/android/src/test/kotlin/dk/nota/flutterreadium/models/FlutterMediaOverlayTest.kt | Tests Android cue-selection rules. |
| flutter_readium/android/src/main/kotlin/dk/nota/flutterreadium/ReadiumReader.kt | Serializes cue commands and updates reader state. |
| flutter_readium/android/src/main/kotlin/dk/nota/flutterreadium/navigators/SyncAudiobookNavigator.kt | Implements cue seeking and explicit visual sync. |
| flutter_readium/android/src/main/kotlin/dk/nota/flutterreadium/models/FlutterMediaOverlay.kt | Adds publication-wide cue selection. |
| flutter_readium_platform_interface/lib/flutter_readium_platform_interface.dart | Documents cue stepping versus time seeking. |
| docs/api-reference/flutter-readium.md | Explains playback-unit behavior across platforms. |
Review effort: Balanced
Member
Author
|
Thanks, worked through all seven.
🤖 Addressed by Claude Code |
Addresses review feedback on the cue-step change: - android: notification seek buttons seek by the interval again instead of stepping a cue. A step reads the position from the Media3 player, which reports a pending seek at once, and awaits the view catch-up out of manual mode while holding the step lock. - ios: resyncToCue awaits the replay, so the serialized queue holds the next step until the view shows this one. - web: queued steps are bound to the navigator active at the tap, and a new navigator starts a fresh chain. A step reads the live clock while paused too, stops when the audio seek fails, and samples the manual flags before the seek so sync emits a single true. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o feat/media-overlay-cue-step * 'main' of https://github.com/Notalib/flutter_readium: (110 commits) fix(web): ignore reader keys pressed with Shift chore(doctor): say the fsmonitor daemon is off, not the setting fix(web): leave Space to DOM buttons and share reader key teardown docs(troubleshooting): run fsmonitor override from the example app test(android): assert every state after a paused goToLocator has progressions fix(android): publish upstream's landed locator after goToLocator fix(web): stop TTS when the speech engine ends without starting fix(android): narrow goToLocator result claims and test the false paths fix(web): turn one page per Space press, back on Shift+Space fix(web): ignore reader key shortcuts meant for the host app chore(release): v0.10.2 fix(android): fill audio locator progression after goToLocator chore(doctor): fail when git core.fsmonitor is enabled on macOS fix(ios): open publications from file:// URL strings fix(web): zoom to the panel of a comic cue that loaded its chapter fix(android): percent-encode file paths when opening a publication fix(android): return navigation result from goToLocator fix(web): keep the newer book open when a superseded open fails fix(web): discard visual navigators from a superseded open fix(web): skip destroyed frames when reaching reader windows ... # Conflicts: # flutter_readium/android/src/main/kotlin/dk/nota/flutterreadium/ReadiumReader.kt
This branch has not been deployed
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.


Summary
In media-overlay books (sync narration, or guided navigation with audio),
next()andprevious()seeked by the time interval, so a listener could not step through the narration sentence by sentence. Now each call steps one narration cue on iOS, Android and web. TTS and plain audiobooks are unchanged, and the public API is unchanged:audioSeekByremains the way to skip by time.Change
next()on the last cue does nothing.previous()follows music-player rules: more than 2 s into a cue restarts that cue; otherwise it goes to the previous cue. On the first cue it restarts that cue.trueemission, and the text never flashes back to the old cue.next()calls land two cues on: a promise chain on web, aMutexon Android, and on iOS aTaskchain on the MainActor that every audiogo(to:)goes through, includinggoToLocatorandgoToProgression.navigator.playback.valueinstead of the derived locator.playbackInfo.currentTimewhile playing.goToLocatordoes. The navigator's throttled locator flow drops a step back to a position it already reported.Review notes
goBoundedcall because overlapping calls clear_isNavigatingearly, which re-exposes a known deadlock. Code already inside the queue usesgoBoundedUnqueued._audioNavPublicationon purpose. The cached_hasSyncNarrationdescribes_publication, which can differ.cueStepTarget/skipToCueon iOS and Android, and infindCueStepTarget/_stepCueon web.Verification
CueStepTargetTestspass.FlutterMediaOverlayTest: 40/40 pass.bin/typecheck,bin/formatandbin/analyzeare clean.timebased_playback_test.dartpass in CI on iOS, Android API 24 and Android API 36. They cover a rapid doublenext(), the single sync emission, and stepping while playing.Not covered
🤖 Generated with Claude Code