mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-16 22:39:34 +00:00
播放逻辑修改
This commit is contained in:
parent
420438c0df
commit
50a27fdf67
33 changed files with 788 additions and 761 deletions
|
|
@ -1,13 +1,13 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:vaani/features/player/core/audiobook_player.dart';
|
||||
import 'package:vaani/shared/audio_player.dart';
|
||||
import 'package:vaani/shared/extensions/chapter.dart';
|
||||
import 'package:vaani/shared/utils/throttler.dart';
|
||||
|
||||
class SkipStartEnd {
|
||||
final Duration start;
|
||||
final Duration end;
|
||||
final AbsAudioHandler player;
|
||||
final AbsAudioPlayer player;
|
||||
|
||||
final List<StreamSubscription> _subscriptions = [];
|
||||
final throttlerStart = Throttler(delay: Duration(seconds: 3));
|
||||
|
|
@ -33,12 +33,12 @@ class SkipStartEnd {
|
|||
}
|
||||
if (end > Duration.zero) {
|
||||
_subscriptions.add(
|
||||
player.positionStreamInChapter.listen((positionChapter) {
|
||||
player.positionInChapterStream.listen((positionChapter) {
|
||||
if (end >
|
||||
(player.currentChapter?.duration ?? Duration.zero) -
|
||||
positionChapter) {
|
||||
Future.microtask(
|
||||
() => throttlerEnd.call(() => player.skipToNext()),
|
||||
() => throttlerEnd.call(() => player.next()),
|
||||
);
|
||||
}
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:vaani/features/per_book_settings/providers/book_settings_provider.dart';
|
||||
import 'package:vaani/features/player/providers/abs_provider.dart';
|
||||
import 'package:vaani/features/player/providers/audiobook_player.dart';
|
||||
import 'package:vaani/features/skip_start_end/core/skip_start_end.dart' as core;
|
||||
|
||||
part 'skip_start_end_provider.g.dart';
|
||||
|
|
@ -16,7 +15,7 @@ class SkipStartEnd extends _$SkipStartEnd {
|
|||
return null;
|
||||
}
|
||||
|
||||
final player = ref.read(playerProvider);
|
||||
final player = ref.read(absAudioPlayerProvider);
|
||||
final bookSettings = ref.watch(bookSettingsProvider(bookId));
|
||||
final start = bookSettings.playerSettings.skipChapterStart;
|
||||
final end = bookSettings.playerSettings.skipChapterEnd;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ part of 'skip_start_end_provider.dart';
|
|||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$skipStartEndHash() => r'ba92dd22fc76f04cb5aaa220d025eb69c9d2ba46';
|
||||
String _$skipStartEndHash() => r'b55dff90ed4ba467e9320d6bc081721336975bdb';
|
||||
|
||||
/// See also [SkipStartEnd].
|
||||
@ProviderFor(SkipStartEnd)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue