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
4a7c592e41
commit
36f14dbd58
4 changed files with 18 additions and 10 deletions
|
|
@ -48,9 +48,11 @@ class AbsAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandler {
|
|||
});
|
||||
// 2. 转发播放位置
|
||||
player.positionStream.listen((Duration position) {
|
||||
playbackState.add(playbackState.value.copyWith(
|
||||
updatePosition: position,
|
||||
));
|
||||
playbackState.add(
|
||||
playbackState.value.copyWith(
|
||||
updatePosition: position,
|
||||
),
|
||||
);
|
||||
});
|
||||
// 3. 转发媒体总时长
|
||||
// player.stream.duration.listen((Duration? duration) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'package:just_audio/just_audio.dart';
|
|||
import 'package:just_audio_media_kit/just_audio_media_kit.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:vaani/features/player/core/abs_audio_player.dart';
|
||||
import 'package:vaani/shared/extensions/chapter.dart';
|
||||
|
||||
final _logger = Logger('AbsPlatformAudioPlayer');
|
||||
|
||||
|
|
@ -9,6 +10,13 @@ final _logger = Logger('AbsPlatformAudioPlayer');
|
|||
class AbsPlatformAudioPlayer extends AbsAudioPlayer {
|
||||
late final AudioPlayer player;
|
||||
AbsPlatformAudioPlayer() {
|
||||
// 跳转到播放列表指定条目指定位置
|
||||
// prefetch-playlist=yes
|
||||
JustAudioMediaKit.prefetchPlaylist = true;
|
||||
// merge-files=yes
|
||||
// cache=yes
|
||||
// cache-pause-wait=60
|
||||
|
||||
JustAudioMediaKit.ensureInitialized();
|
||||
player = AudioPlayer();
|
||||
player.playerStateStream.listen((state) {
|
||||
|
|
@ -31,6 +39,9 @@ class AbsPlatformAudioPlayer extends AbsAudioPlayer {
|
|||
positionInBook <= (chapter?.end ?? Duration.zero)) {
|
||||
final chapter = book?.findChapterAtTime(positionInBook);
|
||||
if (chapter != currentChapter) {
|
||||
print('当前章节时长: ${currentChapter?.duration}');
|
||||
print('切换章节时长: ${chapter?.duration}');
|
||||
print('当前播放音轨时长: ${player.duration}');
|
||||
chapterStreamController.add(chapter);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue