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