This commit is contained in:
rang 2025-12-01 15:34:12 +08:00
parent 1ca8e4889a
commit aad510ea45
31 changed files with 777 additions and 239 deletions

View file

@ -21,13 +21,12 @@ class AudiobookPlayerSeekChapterButton extends HookConsumerWidget {
size: AppElementSizes.iconSizeSmall,
),
onPressed: () {
if (player.session == null) {
if (player.book == null) {
return;
}
// if chapter does not exist, go to the start or end of the book
if (player.currentChapter == null) {
player
.seekInBook(isForward ? player.session!.duration : Duration.zero);
player.seekInBook(isForward ? player.book!.duration : Duration.zero);
return;
}
if (isForward) {

View file

@ -54,7 +54,7 @@ class ChapterSelectionModal extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final session = ref.watch(sessionProvider);
final session = ref.watch(currentBookProvider);
final currentChapter = ref.watch(currentChapterProvider);
final currentChapterIndex = currentChapter?.id;

View file

@ -38,7 +38,7 @@ class AudiobookChapterProgressBar extends HookConsumerWidget {
progress:
currentChapterProgress ?? position.data ?? const Duration(seconds: 0),
total: currentChapter == null
? player.session?.duration ?? const Duration(seconds: 0)
? player.book?.duration ?? const Duration(seconds: 0)
: currentChapter.end - currentChapter.start,
// ! TODO add onSeek
onSeek: (duration) {
@ -74,7 +74,7 @@ class AudiobookProgressBar extends HookConsumerWidget {
height: AppElementSizes.barHeightLarge,
child: LinearProgressIndicator(
value: (position.data ?? const Duration(seconds: 0)).inSeconds /
(player.session?.duration ?? const Duration(seconds: 0)).inSeconds,
(player.book?.duration ?? const Duration(seconds: 0)).inSeconds,
borderRadius: BorderRadiusGeometry.all(Radius.circular(10)),
),
);

View file

@ -17,7 +17,7 @@ class PlayerSpeedAdjustButton extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final player = ref.watch(playerProvider);
final bookId = player.session?.libraryItemId ?? '_';
final bookId = player.book?.libraryItemId ?? '_';
final bookSettings = ref.watch(bookSettingsProvider(bookId));
final appSettings = ref.watch(appSettingsProvider);
return TextButton(