player: add chapter skip buttons

This commit is contained in:
Dr-Blank 2024-05-19 09:45:41 -04:00
parent 6557e63a28
commit 36509913f2
No known key found for this signature in database
GPG key ID: 7452CC63F210A266
4 changed files with 58 additions and 53 deletions

View file

@ -14,13 +14,7 @@ BookExpanded? currentlyPlayingBook(CurrentlyPlayingBookRef ref) {
@riverpod
BookChapter? currentPlayingChapter(CurrentPlayingChapterRef ref) {
final player = ref.watch(audiobookPlayerProvider);
// get the current timestamp
final currentTimestamp = player.position;
// get the chapter that contains the current timestamp
return player.book?.chapters.firstWhere(
(element) =>
element.start <= currentTimestamp && element.end >= currentTimestamp,
);
return player.currentChapter;
}
/// provides the book metadata of the currently playing book