更改播放逻辑

This commit is contained in:
rang 2025-12-08 17:54:08 +08:00
parent 290b68336f
commit 420438c0df
29 changed files with 810 additions and 514 deletions

View file

@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:go_router/go_router.dart';
import 'package:vaani/features/you/view/server_manager.dart';
import 'package:vaani/router/router.dart';
@ -26,12 +25,12 @@ class MyDrawer extends StatelessWidget {
ListTile(
title: const Text('server Settings'),
onTap: () {
Navigator.of(context).push(
platformPageRoute(
context: context,
builder: (context) => const ServerManagerPage(),
),
);
// Navigator.of(context).push(
// PageRoute(
// context: context,
// builder: (context) => const ServerManagerPage(),
// ),
// );
},
),
ListTile(

View file

@ -12,12 +12,9 @@ import 'package:vaani/api/library_item_provider.dart' show libraryItemProvider;
import 'package:vaani/constants/hero_tag_conventions.dart';
import 'package:vaani/features/item_viewer/view/library_item_actions.dart';
import 'package:vaani/features/player/providers/abs_provider.dart';
import 'package:vaani/features/player/providers/currently_playing_provider.dart';
import 'package:vaani/features/player/providers/player_status_provider.dart';
import 'package:vaani/features/player/providers/audiobook_player.dart';
import 'package:vaani/features/settings/app_settings_provider.dart';
import 'package:vaani/router/models/library_item_extras.dart';
import 'package:vaani/router/router.dart';
import 'package:vaani/features/settings/app_settings_provider.dart';
import 'package:vaani/shared/extensions/model_conversions.dart';
import 'package:vaani/shared/widgets/shelves/home_shelf.dart';
import 'package:vaani/theme/providers/theme_from_cover_provider.dart';
@ -215,11 +212,8 @@ class _BookOnShelfPlayButton extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final me = ref.watch(meProvider);
// final player = ref.watch(audiobookPlayerProvider);
final currentBook = ref.watch(absStateProvider.select((v) => v.book));
final playing = ref.watch(absStateProvider.select((v) => v.playing));
// final playerStatus = ref.watch(playerStatusProvider);
// final isLoading = playerStatus.isLoading(libraryItemId);
final currentBook = ref.watch(currentBookProvider);
final playing = ref.watch(playerStateProvider.select((v) => v.playing));
final isCurrentBookSetInPlayer =
currentBook?.libraryItemId == libraryItemId;
final isPlayingThisBook = playing && isCurrentBookSetInPlayer;
@ -300,9 +294,9 @@ class _BookOnShelfPlayButton extends HookConsumerWidget {
// book.media.asBookExpanded,
// userProgress?.currentTime,
// );
ref.read(absStateProvider.notifier).load(
ref.read(absAudioPlayerProvider.notifier).load(
book.media.asBookExpanded,
userProgress?.currentTime,
initialPosition: userProgress?.currentTime,
);
},
icon: Hero(
@ -355,7 +349,7 @@ class BookCoverWidget extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final currentBook = ref.watch(absStateProvider.select((v) => v.book));
final currentBook = ref.watch(currentBookProvider);
if (currentBook == null) {
return const BookCoverSkeleton();
}

View file

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:tray_manager/tray_manager.dart';
import 'package:vaani/features/player/providers/audiobook_player.dart';
import 'package:vaani/features/player/providers/abs_provider.dart';
import 'package:vaani/globals.dart';
import 'package:vaani/shared/utils/helper.dart';
import 'package:window_manager/window_manager.dart';
@ -46,17 +46,17 @@ class _TrayManagerState extends ConsumerState<TrayManager>
MenuItem(
key: 'play_pause',
label: '播放/暂停',
onClick: (menuItem) => ref.read(playerProvider).togglePlayPause(),
onClick: (menuItem) => ref.read(absAudioPlayerProvider).playOrPause(),
),
MenuItem(
key: 'previous',
label: '上一个',
onClick: (menuItem) => ref.read(playerProvider).skipToPrevious(),
onClick: (menuItem) => ref.read(absAudioPlayerProvider).previous(),
),
MenuItem(
key: 'next',
label: '下一个',
onClick: (menuItem) => ref.read(playerProvider).skipToNext(),
onClick: (menuItem) => ref.read(absAudioPlayerProvider).next(),
),
MenuItem.separator(),
MenuItem(