mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-17 06:49:34 +00:00
123
This commit is contained in:
parent
4a7c592e41
commit
36f14dbd58
4 changed files with 18 additions and 10 deletions
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
|
@ -15,6 +15,7 @@
|
||||||
"mocktail",
|
"mocktail",
|
||||||
"nodename",
|
"nodename",
|
||||||
"numberpicker",
|
"numberpicker",
|
||||||
|
"nvalue",
|
||||||
"Prefs",
|
"Prefs",
|
||||||
"riverpod",
|
"riverpod",
|
||||||
"Schyler",
|
"Schyler",
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,11 @@ class AbsAudioHandler extends BaseAudioHandler with QueueHandler, SeekHandler {
|
||||||
});
|
});
|
||||||
// 2. 转发播放位置
|
// 2. 转发播放位置
|
||||||
player.positionStream.listen((Duration position) {
|
player.positionStream.listen((Duration position) {
|
||||||
playbackState.add(playbackState.value.copyWith(
|
playbackState.add(
|
||||||
updatePosition: position,
|
playbackState.value.copyWith(
|
||||||
));
|
updatePosition: position,
|
||||||
|
),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
// 3. 转发媒体总时长
|
// 3. 转发媒体总时长
|
||||||
// player.stream.duration.listen((Duration? duration) {
|
// 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:just_audio_media_kit/just_audio_media_kit.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:vaani/features/player/core/abs_audio_player.dart';
|
import 'package:vaani/features/player/core/abs_audio_player.dart';
|
||||||
|
import 'package:vaani/shared/extensions/chapter.dart';
|
||||||
|
|
||||||
final _logger = Logger('AbsPlatformAudioPlayer');
|
final _logger = Logger('AbsPlatformAudioPlayer');
|
||||||
|
|
||||||
|
|
@ -9,6 +10,13 @@ final _logger = Logger('AbsPlatformAudioPlayer');
|
||||||
class AbsPlatformAudioPlayer extends AbsAudioPlayer {
|
class AbsPlatformAudioPlayer extends AbsAudioPlayer {
|
||||||
late final AudioPlayer player;
|
late final AudioPlayer player;
|
||||||
AbsPlatformAudioPlayer() {
|
AbsPlatformAudioPlayer() {
|
||||||
|
// 跳转到播放列表指定条目指定位置
|
||||||
|
// prefetch-playlist=yes
|
||||||
|
JustAudioMediaKit.prefetchPlaylist = true;
|
||||||
|
// merge-files=yes
|
||||||
|
// cache=yes
|
||||||
|
// cache-pause-wait=60
|
||||||
|
|
||||||
JustAudioMediaKit.ensureInitialized();
|
JustAudioMediaKit.ensureInitialized();
|
||||||
player = AudioPlayer();
|
player = AudioPlayer();
|
||||||
player.playerStateStream.listen((state) {
|
player.playerStateStream.listen((state) {
|
||||||
|
|
@ -31,6 +39,9 @@ class AbsPlatformAudioPlayer extends AbsAudioPlayer {
|
||||||
positionInBook <= (chapter?.end ?? Duration.zero)) {
|
positionInBook <= (chapter?.end ?? Duration.zero)) {
|
||||||
final chapter = book?.findChapterAtTime(positionInBook);
|
final chapter = book?.findChapterAtTime(positionInBook);
|
||||||
if (chapter != currentChapter) {
|
if (chapter != currentChapter) {
|
||||||
|
print('当前章节时长: ${currentChapter?.duration}');
|
||||||
|
print('切换章节时长: ${chapter?.duration}');
|
||||||
|
print('当前播放音轨时长: ${player.duration}');
|
||||||
chapterStreamController.add(chapter);
|
chapterStreamController.add(chapter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,16 +20,10 @@ class SkipStartEnd {
|
||||||
}) {
|
}) {
|
||||||
if (start > Duration.zero) {
|
if (start > Duration.zero) {
|
||||||
_subscriptions.add(
|
_subscriptions.add(
|
||||||
player.chapterStream.listen((chapter) {
|
player.chapterStream.listen((chapter) async {
|
||||||
if (chapter != null &&
|
if (chapter != null &&
|
||||||
player.positionInChapter < Duration(seconds: 1)) {
|
player.positionInChapter < Duration(seconds: 1)) {
|
||||||
// player.pause();
|
|
||||||
player.seekInBook(chapter.start + start);
|
player.seekInBook(chapter.start + start);
|
||||||
// player.play();
|
|
||||||
// Future.microtask(
|
|
||||||
// () => throttlerStart
|
|
||||||
// .call(() => player.seekInBook(chapter.start + start)),
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue