一堆乱七八糟的修改

播放页面增加桌面版
This commit is contained in:
rang 2025-11-28 17:05:35 +08:00
parent aee1fbde88
commit 3ba35b31b8
116 changed files with 1238 additions and 2592 deletions

View file

@ -0,0 +1,58 @@
import 'dart:async';
import 'package:vaani/features/player/core/audiobook_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 List<StreamSubscription> _subscriptions = [];
final throttlerStart = Throttler(delay: Duration(seconds: 3));
final throttlerEnd = Throttler(delay: Duration(seconds: 3));
SkipStartEnd({
required this.start,
required this.end,
required this.player,
}) {
if (start > Duration.zero) {
_subscriptions.add(
player.chapterStream.listen((chapter) {
if (chapter != null &&
player.positionInChapter < Duration(seconds: 1)) {
Future.microtask(
() => throttlerStart
.call(() => player.seekInBook(chapter.start + start)),
);
}
}),
);
}
if (end > Duration.zero) {
_subscriptions.add(
player.positionStreamInChapter.listen((positionChapter) {
if (end >
(player.currentChapter?.duration ?? Duration.zero) -
positionChapter) {
Future.microtask(
() => throttlerEnd.call(() => player.skipToNext()),
);
}
}),
);
}
}
/// dispose the timer
void dispose() {
for (var sub in _subscriptions) {
sub.cancel();
}
throttlerStart.dispose();
throttlerEnd.dispose();
// _playbackController.close();
}
}