mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-16 14:29:35 +00:00
123
This commit is contained in:
parent
178f3fbdb1
commit
634ffaed8c
27 changed files with 648 additions and 1012 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:vaani/features/player/providers/abs_provider.dart'
|
||||
hide PlayerState;
|
||||
import 'package:vaani/features/player/core/abs_audio_player.dart';
|
||||
|
||||
class AudiobookPlayerPlayPauseButton extends HookConsumerWidget {
|
||||
const AudiobookPlayerPlayPauseButton({
|
||||
|
|
@ -21,12 +21,12 @@ class AudiobookPlayerPlayPauseButton extends HookConsumerWidget {
|
|||
);
|
||||
}
|
||||
|
||||
Widget _getIcon(AbsPlayerState playerState, BuildContext context) {
|
||||
Widget _getIcon(PlayerState playerState, BuildContext context) {
|
||||
if (playerState.playing) {
|
||||
return Icon(size: iconSize, Icons.pause);
|
||||
} else {
|
||||
switch (playerState.processingState) {
|
||||
case AbsProcessingState.loading || AbsProcessingState.buffering:
|
||||
case ProcessingState.loading || ProcessingState.buffering:
|
||||
return CircularProgressIndicator();
|
||||
default:
|
||||
return Icon(size: iconSize, Icons.play_arrow);
|
||||
|
|
@ -34,13 +34,13 @@ class AudiobookPlayerPlayPauseButton extends HookConsumerWidget {
|
|||
}
|
||||
}
|
||||
|
||||
void _actionButtonPressed(AbsPlayerState playerState, WidgetRef ref) async {
|
||||
void _actionButtonPressed(PlayerState playerState, WidgetRef ref) async {
|
||||
final player = ref.read(absPlayerProvider);
|
||||
if (playerState.playing) {
|
||||
await player.pause();
|
||||
} else {
|
||||
switch (playerState.processingState) {
|
||||
case AbsProcessingState.completed:
|
||||
case ProcessingState.completed:
|
||||
await player.seekInBook(const Duration(seconds: 0));
|
||||
await player.play();
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ class AudiobookChapterProgressBar extends HookConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final book = ref.watch(currentBookProvider);
|
||||
final player = ref.watch(absPlayerProvider);
|
||||
final currentChapter = ref.watch(currentChapterProvider);
|
||||
final position = useStream(
|
||||
|
|
@ -36,7 +37,7 @@ class AudiobookChapterProgressBar extends HookConsumerWidget {
|
|||
final progress =
|
||||
currentChapterProgress ?? position.data ?? const Duration(seconds: 0);
|
||||
final total = currentChapter == null
|
||||
? player.book?.duration ?? const Duration(seconds: 0)
|
||||
? book?.duration ?? const Duration(seconds: 0)
|
||||
: currentChapter.end - currentChapter.start;
|
||||
return ProgressBar(
|
||||
progress: progress,
|
||||
|
|
@ -65,6 +66,7 @@ class AudiobookProgressBar extends HookConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final book = ref.watch(currentBookProvider);
|
||||
final player = ref.read(absPlayerProvider);
|
||||
final position = useStream(
|
||||
player.positionInBookStream,
|
||||
|
|
@ -75,7 +77,7 @@ class AudiobookProgressBar extends HookConsumerWidget {
|
|||
height: AppElementSizes.barHeightLarge,
|
||||
child: LinearProgressIndicator(
|
||||
value: (position.data ?? const Duration(seconds: 0)).inSeconds /
|
||||
(player.book?.duration ?? const Duration(seconds: 0)).inSeconds,
|
||||
(book?.duration ?? const Duration(seconds: 0)).inSeconds,
|
||||
borderRadius: BorderRadiusGeometry.all(Radius.circular(10)),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue