diff --git a/lib/pages/setting/widgets/model.dart b/lib/pages/setting/widgets/model.dart index f718ffbce..5b16f2fda 100644 --- a/lib/pages/setting/widgets/model.dart +++ b/lib/pages/setting/widgets/model.dart @@ -1573,6 +1573,13 @@ List get extraSettings => [ needReboot: true, setKey: SettingBoxKey.badCertificateCallback, ), + SettingsModel( + settingsType: SettingsType.sw1tch, + title: '显示继续播放分P提示', + leading: Icon(Icons.local_parking), + setKey: SettingBoxKey.continuePlayingPart, + defaultVal: true, + ), SettingsModel( settingsType: SettingsType.sw1tch, enableFeedback: true, diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index ce34ff862..7b81b28da 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -1830,9 +1830,9 @@ class VideoDetailController extends GetxController }; } - List> _vttSubtitles = >[]; + late List> _vttSubtitles = >[]; int? vttSubtitlesIndex; - bool showVP = true; + late bool showVP = true; void _getSubtitle() { _vttSubtitles.clear(); @@ -1865,63 +1865,69 @@ class VideoDetailController extends GetxController }); } + late bool continuePlayingPart = GStorage.continuePlayingPart; + Future _querySubtitles() async { Map res = await VideoHttp.subtitlesJson(bvid: bvid, cid: cid.value); // if (!res["status"]) { // SmartDialog.showToast('查询字幕错误,${res["msg"]}'); // } if (res['status']) { - try { - VideoIntroController videoIntroController = - Get.find(tag: heroTag); - if ((videoIntroController.videoDetail.value.pages?.length ?? 0) > 1 && - res['last_play_cid'] != null && - res['last_play_cid'] != 0) { - if (res['last_play_cid'] != cid.value) { - int index = videoIntroController.videoDetail.value.pages! - .indexWhere((item) => item.cid == res['last_play_cid']); - if (index != -1) { - SmartDialog.showAttach( - targetContext: childKey.currentContext, - alignment: Alignment.topCenter, - maskColor: Colors.transparent, - displayTime: Duration(seconds: 4), - builder: (context) => GestureDetector( - onTap: () { - SmartDialog.dismiss(); - Part part = - videoIntroController.videoDetail.value.pages![index]; - videoIntroController.changeSeasonOrbangu( - null, - bvid, - part.cid, - IdUtils.bv2av(bvid), - null, - ); - }, - child: Container( - padding: - const EdgeInsets.symmetric(horizontal: 8, vertical: 4), - margin: const EdgeInsets.only(bottom: 15), - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.secondaryContainer, - borderRadius: BorderRadius.circular(8), - ), - child: Text( - '上次看到第${index + 1}P,点击跳转', - style: TextStyle( - fontSize: 14, - color: - Theme.of(context).colorScheme.onSecondaryContainer, + if (continuePlayingPart) { + continuePlayingPart = false; + try { + VideoIntroController videoIntroController = + Get.find(tag: heroTag); + if ((videoIntroController.videoDetail.value.pages?.length ?? 0) > 1 && + res['last_play_cid'] != null && + res['last_play_cid'] != 0) { + if (res['last_play_cid'] != cid.value) { + int index = videoIntroController.videoDetail.value.pages! + .indexWhere((item) => item.cid == res['last_play_cid']); + if (index != -1) { + SmartDialog.showAttach( + targetContext: childKey.currentContext, + alignment: Alignment.topCenter, + maskColor: Colors.transparent, + displayTime: Duration(seconds: 4), + builder: (context) => GestureDetector( + onTap: () { + SmartDialog.dismiss(); + Part part = + videoIntroController.videoDetail.value.pages![index]; + videoIntroController.changeSeasonOrbangu( + null, + bvid, + part.cid, + IdUtils.bv2av(bvid), + null, + ); + }, + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 8, vertical: 4), + margin: const EdgeInsets.only(bottom: 15), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.secondaryContainer, + borderRadius: BorderRadius.circular(8), + ), + child: Text( + '上次看到第${index + 1}P,点击跳转', + style: TextStyle( + fontSize: 14, + color: Theme.of(context) + .colorScheme + .onSecondaryContainer, + ), ), ), ), - ), - ); + ); + } } } - } - } catch (_) {} + } catch (_) {} + } vttSubtitlesIndex = 0; if (res["data"] is List && res["data"].isNotEmpty) { diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 54bb9f5b3..dfdf697c0 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -287,6 +287,9 @@ class GStorage { static bool get badCertificateCallback => setting.get(SettingBoxKey.badCertificateCallback, defaultValue: false); + static bool get continuePlayingPart => + setting.get(SettingBoxKey.continuePlayingPart, defaultValue: true); + static List get dynamicDetailRatio => List.from(setting .get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0])); @@ -495,6 +498,7 @@ class SettingBoxKey { subtitleBgOpaticy = 'subtitleBgOpaticy', subtitleBgStroke = 'subtitleBgStroke', badCertificateCallback = 'badCertificateCallback', + continuePlayingPart = 'continuePlayingPart', // Sponsor Block enableSponsorBlock = 'enableSponsorBlock',