From 1a327198f72e5a4e1cff622602098fb92d847b1a Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Thu, 30 Jan 2025 15:52:51 +0800 Subject: [PATCH] opt: video: onreset Signed-off-by: bggRGjQaUbCoE --- .../bangumi/introduction/controller.dart | 6 +--- lib/pages/video/detail/controller.dart | 28 +++++++++++++++++-- .../video/detail/introduction/controller.dart | 6 +--- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/lib/pages/bangumi/introduction/controller.dart b/lib/pages/bangumi/introduction/controller.dart index 455be819..0183a01f 100644 --- a/lib/pages/bangumi/introduction/controller.dart +++ b/lib/pages/bangumi/introduction/controller.dart @@ -418,11 +418,7 @@ class BangumiIntroController extends CommonController { Get.find(tag: Get.arguments['heroTag']) ..plPlayerController.pause() ..makeHeartBeat() - ..playedTime = null - ..videoUrl = null - ..audioUrl = null - ..vttSubtitlesIndex = null - ..savedDanmaku = null + ..onReset() ..epId = epId ..bvid = bvid ..cid.value = cid diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index d4d655ad..7d16fc7a 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -635,6 +635,9 @@ class VideoDetailController extends GetxController Future _querySponsorBlock() async { positionSubscription?.cancel(); + videoLabel.value = ''; + segmentList.clear(); + _segmentProgressList = null; dynamic result = await Request().get( '${GStorage.blockServer}/api/skipSegments', queryParameters: { @@ -643,9 +646,6 @@ class VideoDetailController extends GetxController }, options: _options, ); - videoLabel.value = ''; - segmentList.clear(); - _segmentProgressList = null; _handleSBData(result); } @@ -1963,4 +1963,26 @@ class VideoDetailController extends GetxController tabCtr.dispose(); super.onClose(); } + + onReset() { + playedTime = null; + videoUrl = null; + audioUrl = null; + + // danmaku + savedDanmaku = null; + + // subtitle + vttSubtitlesIndex = null; + _vttSubtitles.clear(); + + // view point + viewPointList.clear(); + + // sponsor block + positionSubscription?.cancel(); + videoLabel.value = ''; + segmentList.clear(); + _segmentProgressList = null; + } } diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index 29c52677..91347fe0 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -583,12 +583,8 @@ class VideoIntroController extends GetxController final videoDetailCtr = Get.find(tag: heroTag) ..plPlayerController.pause() ..makeHeartBeat() - ..playedTime = null - ..videoUrl = null - ..audioUrl = null ..updateMediaListHistory(aid) - ..vttSubtitlesIndex = null - ..savedDanmaku = null + ..onReset() ..bvid = bvid ..oid.value = aid ?? IdUtils.bv2av(bvid) ..cid.value = cid