diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index bab3168b..601baefb 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -139,7 +139,7 @@ class _ExtraSettingState extends State { body: ListView( children: [ SetSwitchItem( - title: 'Sponsor Block', + title: '空降助手', subTitle: '点击配置', leading: Icon(Icons.block), setKey: SettingBoxKey.enableSponsorBlock, diff --git a/lib/pages/setting/sponsor_block_page.dart b/lib/pages/setting/sponsor_block_page.dart index 7f472fce..829c5843 100644 --- a/lib/pages/setting/sponsor_block_page.dart +++ b/lib/pages/setting/sponsor_block_page.dart @@ -134,7 +134,7 @@ class _SponsorBlockPageState extends State { Widget get _aboudItem => ListTile( dense: true, - title: Text('关于 SponsorBlock', style: _titleStyle), + title: Text('关于空降助手', style: _titleStyle), subtitle: Text(_url, style: _subTitleStyle), onTap: () => Utils.launchURL(_url), ); @@ -248,9 +248,14 @@ class _SponsorBlockPageState extends State { dense: true, onTap: _updateBlockTrack, title: Text( - '记录跳过片段', + '跳过次数统计跟踪', style: _titleStyle, ), + subtitle: Text( + // from origin extension + '此功能追踪您跳过了哪些片段,让用户知道他们提交的片段帮助了多少人。同时点赞会作为依据,确保垃圾信息不会污染数据库。在您每次跳过片段时,我们都会向服务器发送一条消息。希望大家开启此项设置,以便得到更准确的统计数据。:)', + style: _subTitleStyle, + ), trailing: Transform.scale( alignment: Alignment.centerRight, scale: 0.8, @@ -368,7 +373,7 @@ class _SponsorBlockPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Sponsor Block')), + appBar: AppBar(title: Text('空降助手')), body: CustomScrollView( slivers: [ _dividerL, diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index 770704bc..0e14563a 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -133,6 +133,10 @@ class PostSegmentModel { enum ActionType { skip, mute, full, poi } +extension ActionTypeExt on ActionType { + String get title => ['跳过', '静音', '整个视频', '精彩时刻'][index]; +} + class VideoDetailController extends GetxController with GetSingleTickerProviderStateMixin { /// 路由传参 @@ -1234,9 +1238,11 @@ class VideoDetailController extends GetxController PopupMenuButton( initialValue: list![index].category, onSelected: (item) async { - setState(() { - list![index].category = item; - }); + list![index].category = item; + list![index].actionType = + _segmentType2ActionType(item) + .first; + setState(() {}); }, itemBuilder: (context) => SegmentType.values @@ -1273,7 +1279,7 @@ class VideoDetailController extends GetxController ), ), const SizedBox(width: 16), - const Text('ActionType: '), + const Text('行为类别: '), PopupMenuButton( initialValue: list![index].actionType, @@ -1284,11 +1290,18 @@ class VideoDetailController extends GetxController }, itemBuilder: (context) => ActionType .values - .map((item) => - PopupMenuItem( - value: item, - child: Text(item.name), - )) + .map( + (item) => + PopupMenuItem( + enabled: + _segmentType2ActionType( + list![index] + .category) + .contains(item), + value: item, + child: Text(item.title), + ), + ) .toList(), child: Row( mainAxisSize: MainAxisSize.min, @@ -1296,7 +1309,7 @@ class VideoDetailController extends GetxController CrossAxisAlignment.start, children: [ Text( - list![index].actionType.name, + list![index].actionType.title, style: TextStyle( fontSize: 14, color: Theme.of(context) @@ -1369,6 +1382,9 @@ class VideoDetailController extends GetxController _handleSBData(res); plPlayerController.segmentList.value = _segmentProgressList ?? []; + if (positionSubscription == null) { + _initSkip(); + } } else { SmartDialog.showToast( '提交失败: ${{ @@ -1392,4 +1408,76 @@ class VideoDetailController extends GetxController ); }, ); + + List _actionType2SegmentType(ActionType actionType) { + return switch (actionType) { + ActionType.skip => [ + SegmentType.sponsor, + SegmentType.selfpromo, + SegmentType.interaction, + SegmentType.intro, + SegmentType.outro, + SegmentType.preview, + SegmentType.filler, + ], + ActionType.mute => [ + SegmentType.sponsor, + SegmentType.selfpromo, + SegmentType.interaction, + SegmentType.intro, + SegmentType.outro, + SegmentType.preview, + SegmentType.music_offtopic, + SegmentType.filler, + ], + ActionType.full => [ + SegmentType.sponsor, + SegmentType.selfpromo, + SegmentType.exclusive_access, + ], + ActionType.poi => [ + SegmentType.poi_highlight, + ], + }; + } + + List _segmentType2ActionType(SegmentType segmentType) { + return switch (segmentType) { + SegmentType.sponsor => [ + ActionType.skip, + ActionType.mute, + ActionType.full + ], + SegmentType.selfpromo => [ + ActionType.skip, + ActionType.mute, + ActionType.full + ], + SegmentType.interaction => [ + ActionType.skip, + ActionType.mute, + ], + SegmentType.intro => [ + ActionType.skip, + ActionType.mute, + ], + SegmentType.outro => [ + ActionType.skip, + ActionType.mute, + ], + SegmentType.preview => [ + ActionType.skip, + ActionType.mute, + ], + SegmentType.music_offtopic => [ + ActionType.mute, + ], + SegmentType.poi_highlight => [ActionType.poi], + SegmentType.filler => [ + ActionType.skip, + ActionType.mute, + ], + SegmentType.exclusive_access => [ActionType.full], + }; + } }