mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-16 14:29:35 +00:00
播放器重写的stream改名
This commit is contained in:
parent
05bc0cde74
commit
e44144b229
6 changed files with 14 additions and 13 deletions
|
|
@ -271,8 +271,7 @@ class AudiobookPlayer extends AudioPlayer {
|
|||
// - positionStream
|
||||
// - bufferedPositionStream
|
||||
|
||||
@override
|
||||
Stream<Duration> get positionStream {
|
||||
Stream<Duration> get positionStreamInBook {
|
||||
// return the positionInBook stream
|
||||
return super.positionStream.map((position) {
|
||||
if (_book == null) {
|
||||
|
|
@ -282,8 +281,7 @@ class AudiobookPlayer extends AudioPlayer {
|
|||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<Duration> get bufferedPositionStream {
|
||||
Stream<Duration> get bufferedPositionStreamInBook {
|
||||
return super.bufferedPositionStream.map((position) {
|
||||
if (_book == null) {
|
||||
return Duration.zero;
|
||||
|
|
@ -293,7 +291,7 @@ class AudiobookPlayer extends AudioPlayer {
|
|||
}
|
||||
|
||||
/// a convenience getter for slow position stream
|
||||
Stream<Duration> get slowPositionStream {
|
||||
Stream<Duration> get slowPositionStreamInBook {
|
||||
final superPositionStream = createPositionStream(
|
||||
steps: 100,
|
||||
minPeriod: const Duration(milliseconds: 500),
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ BookExpanded? currentlyPlayingBook(Ref ref) {
|
|||
@riverpod
|
||||
BookChapter? currentPlayingChapter(Ref ref) {
|
||||
final player = ref.watch(audiobookPlayerProvider);
|
||||
player.slowPositionStream.listen((_) {
|
||||
player.slowPositionStreamInBook.listen((_) {
|
||||
ref.invalidateSelf();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ final currentlyPlayingBookProvider =
|
|||
// ignore: unused_element
|
||||
typedef CurrentlyPlayingBookRef = AutoDisposeProviderRef<BookExpanded?>;
|
||||
String _$currentPlayingChapterHash() =>
|
||||
r'73db8b8a9058573bb0c68ec5d5f8aba9306f3d24';
|
||||
r'4a64157089279c71279ccfdbcfc7b32543ecc88c';
|
||||
|
||||
/// provided the current chapter of the book being played
|
||||
///
|
||||
|
|
|
|||
|
|
@ -197,11 +197,11 @@ class AudiobookChapterProgressBar extends HookConsumerWidget {
|
|||
final player = ref.watch(audiobookPlayerProvider);
|
||||
final currentChapter = ref.watch(currentPlayingChapterProvider);
|
||||
final position = useStream(
|
||||
player.positionStream,
|
||||
player.positionStreamInBook,
|
||||
initialData: const Duration(seconds: 0),
|
||||
);
|
||||
final buffered = useStream(
|
||||
player.bufferedPositionStream,
|
||||
player.bufferedPositionStreamInBook,
|
||||
initialData: const Duration(seconds: 0),
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class PlayerWhenMinimized extends HookConsumerWidget {
|
|||
final currentChapter = ref.watch(currentPlayingChapterProvider);
|
||||
|
||||
final vanishingPercentage = 1 - percentageMiniplayer;
|
||||
final progress = useStream(player.slowPositionStream, initialData: Duration.zero);
|
||||
final progress = useStream(player.slowPositionStreamInBook, initialData: Duration.zero);
|
||||
|
||||
final bookMetaExpanded = ref.watch(currentBookMetadataProvider);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ class SkipStartEnd {
|
|||
_subscriptions.add(
|
||||
player.currentIndexStream.listen((index) {
|
||||
if (_index != index && player.position.inMilliseconds < 500) {
|
||||
_index = index!;
|
||||
Future.microtask(() {
|
||||
player.seek(start);
|
||||
});
|
||||
_index = index!;
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
|
@ -31,8 +31,11 @@ class SkipStartEnd {
|
|||
if (player.duration != null &&
|
||||
player.duration!.inMilliseconds - player.position.inMilliseconds <
|
||||
end.inMilliseconds) {
|
||||
Future.microtask(() {
|
||||
throttler.call(player.seekForward);
|
||||
throttler.call(() {
|
||||
print('跳过片尾');
|
||||
Future.microtask(() {
|
||||
throttler.call(player.seekToNext);
|
||||
});
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue