fix(player): 修复详情往返播放位置丢失
This commit is contained in:
1 parent
fe49c6d8b2
commit
759a02375a
16 files changed
+464
-5
No files matched your search
@@ -11,6 +11,7 @@ import '../../core/data/repositories/watch_history_repository.dart';
|
||||
import '../../core/data/repositories/playback_repository.dart';
|
||||
import '../../core/data/services/favorite_controller.dart';
|
||||
import '../../core/data/services/download_controller.dart';
|
||||
import '../../core/data/services/playback_position_cache.dart';
|
||||
import '../../core/data/services/wallet_controller.dart';
|
||||
import '../player/player_view.dart';
|
||||
|
||||
@@ -20,6 +21,7 @@ class DramaDetailLogic extends ChangeNotifier {
|
||||
required this.history,
|
||||
required this.playback,
|
||||
required this.favorites,
|
||||
required this.positionCache,
|
||||
});
|
||||
|
||||
/// 先用列表卡片渲染,取到详情后换成带完整剧集的版本。
|
||||
@@ -27,6 +29,7 @@ class DramaDetailLogic extends ChangeNotifier {
|
||||
final WatchHistoryRepository history;
|
||||
final PlaybackRepository playback;
|
||||
final FavoriteController favorites;
|
||||
final PlaybackPositionCache positionCache;
|
||||
bool loading = false;
|
||||
bool failed = false;
|
||||
|
||||
@@ -71,6 +74,23 @@ class DramaDetailLogic extends ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> loadContinue() async {
|
||||
final cached = positionCache.latestForDrama(drama.id);
|
||||
if (cached != null) {
|
||||
final index = _indexOf(cached.episodeId);
|
||||
if (index != null) {
|
||||
progress = WatchProgress(
|
||||
dramaId: cached.dramaId,
|
||||
episodeId: cached.episodeId,
|
||||
position: cached.position,
|
||||
duration: cached.duration,
|
||||
updatedAt: cached.updatedAt,
|
||||
);
|
||||
continueIndex = index;
|
||||
progressError = null;
|
||||
notify();
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
final record = await history.progressFor(drama.id);
|
||||
if (_disposed) return;
|
||||
|
||||
Reference in new issue
Block a user