feat(player): 倍速改为底部弹窗选择

This commit is contained in:
Zhou Weidong committed 2026-10-19 17:32:17 +08:00
1 parent 5ca5846a26
commit 3a7e0bc4b7
10 files changed
+194 -6

No files matched your search

+12
View File
@@ -68,6 +68,7 @@ class PlayerLogic extends ChangeNotifier {
List<Episode> sessionEpisodes = const [];
int pageRequest = 0;
bool muted = false;
double playbackSpeed = 1.0;
bool stoppedAtFeedEnd = false;
VideoPlayerPort? scrubbingPlayer;
bool pip = false;
@@ -341,6 +342,7 @@ class PlayerLogic extends ChangeNotifier {
Future<void> preparePlayer(Episode episode, PlayerPort player) async {
if (player is! VideoPlayerPort) return;
try {
await player.controller.setPlaybackSpeed(playbackSpeed);
await pendingWrite;
// 服务端每剧只记一条:只有"记录里的那一集"才定位,其它集从头播
if (resumePoint == null) await loadResumePoint();
@@ -360,6 +362,7 @@ class PlayerLogic extends ChangeNotifier {
final index = session.currentIndex;
final drama = queue.entryAt(index).drama;
await player.controller.setVolume(muted ? 0 : 1);
await player.controller.setPlaybackSpeed(playbackSpeed);
if (session.active != player) return;
trackedPlayer = player;
trackedEpisode = episode;
@@ -787,6 +790,15 @@ class PlayerLogic extends ChangeNotifier {
notify();
}
Future<void> setPlaybackSpeed(double value) async {
playbackSpeed = value;
final active = session.active;
if (active is VideoPlayerPort && active.controller.value.isInitialized) {
await active.controller.setPlaybackSpeed(value);
}
notify();
}
Future<void> showComments(BuildContext context, Drama drama) async {
session.setOverlayOpen(true);
await session.playbackSettled;