mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2025-12-06 02:59:28 +00:00
Refactor chapter seeking logic in AudiobookPlayerSeekChapterButton
This commit is contained in:
parent
2f078742d0
commit
b2130a53cc
6 changed files with 27 additions and 88 deletions
|
|
@ -204,6 +204,22 @@ class AudiobookPlayer extends AudioPlayer {
|
|||
});
|
||||
}
|
||||
|
||||
/// a convenience getter for slow position stream
|
||||
Stream<Duration> get slowPositionStream {
|
||||
final superPositionStream = createPositionStream(
|
||||
steps: 100,
|
||||
minPeriod: const Duration(milliseconds: 500),
|
||||
maxPeriod: const Duration(seconds: 1),
|
||||
);
|
||||
// now we need to map the position to the book instead of the current track
|
||||
return superPositionStream.map((position) {
|
||||
if (_book == null) {
|
||||
return Duration.zero;
|
||||
}
|
||||
return position + _book!.tracks[sequenceState!.currentIndex].startOffset;
|
||||
});
|
||||
}
|
||||
|
||||
/// get current chapter
|
||||
BookChapter? get currentChapter {
|
||||
if (_book == null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue