From fa75f5c54238fbab84dce40eb8b61186e267edd2 Mon Sep 17 00:00:00 2001 From: Esing <91776041+Zxis233@users.noreply.github.com> Date: Fri, 24 Jul 2026 12:33:33 +0800 Subject: [PATCH] fix: resume history from the recording account progress (#2458) --- lib/models_new/history/list.dart | 12 ++++++++++++ lib/pages/history/widgets/item.dart | 7 ++++++- lib/utils/page_utils.dart | 3 +++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/models_new/history/list.dart b/lib/models_new/history/list.dart index 21540a18b..76d0cbb5c 100644 --- a/lib/models_new/history/list.dart +++ b/lib/models_new/history/list.dart @@ -21,6 +21,18 @@ class HistoryItemModel with MultiSelectData { String? tagName; int? liveStatus; + /// The history API uses seconds as the progress unit + /// while the player expects milliseconds. + /// + /// The history API uses `-1` to indicate that the video has been fully watched. + /// When reopened, playback should start from the beginning to avoid resuming from + /// the last playback position associated with the video streaming account. + int? get playbackProgress { + final progress = this.progress; + if (progress == null) return null; + return progress == -1 ? 0 : progress * Duration.millisecondsPerSecond; + } + HistoryItemModel({ this.title, this.cover, diff --git a/lib/pages/history/widgets/item.dart b/lib/pages/history/widgets/item.dart index 2c06d7f39..9b7fb42ba 100644 --- a/lib/pages/history/widgets/item.dart +++ b/lib/pages/history/widgets/item.dart @@ -69,13 +69,17 @@ class HistoryItem extends StatelessWidget { SmartDialog.showToast('直播未开播'); } } else if (business == 'pgc') { - PageUtils.viewPgc(epId: item.history.epid); + PageUtils.viewPgc( + epId: item.history.epid, + progress: item.playbackProgress, + ); } else if (business == 'cheese') { if (item.uri?.isNotEmpty == true) { PageUtils.viewPgcFromUri( item.uri!, isPgc: false, aid: item.history.oid, + progress: item.playbackProgress, ); } } else { @@ -101,6 +105,7 @@ class HistoryItem extends StatelessWidget { cover: item.cover, title: item.title, dimension: dimension, + progress: item.playbackProgress, ); } } diff --git a/lib/utils/page_utils.dart b/lib/utils/page_utils.dart index 464a72168..817d4afff 100644 --- a/lib/utils/page_utils.dart +++ b/lib/utils/page_utils.dart @@ -624,6 +624,7 @@ abstract final class PageUtils { seasonId: isSeason ? id : null, epId: isSeason ? null : id, aid: aid, + progress: progress, off: off, ); } @@ -752,6 +753,7 @@ abstract final class PageUtils { dynamic seasonId, dynamic epId, int? aid, + int? progress, // milliseconds bool off = false, }) async { try { @@ -777,6 +779,7 @@ abstract final class PageUtils { seasonId: response.seasonId, epId: episode.id, cover: episode.cover, + progress: progress, extraArguments: { 'pgcItem': response, },