opt: post segments

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-11-26 14:32:53 +08:00
parent 6fee468f49
commit 4f4f000e98
3 changed files with 107 additions and 14 deletions

View File

@@ -139,7 +139,7 @@ class _ExtraSettingState extends State<ExtraSetting> {
body: ListView( body: ListView(
children: [ children: [
SetSwitchItem( SetSwitchItem(
title: 'Sponsor Block', title: '空降助手',
subTitle: '点击配置', subTitle: '点击配置',
leading: Icon(Icons.block), leading: Icon(Icons.block),
setKey: SettingBoxKey.enableSponsorBlock, setKey: SettingBoxKey.enableSponsorBlock,

View File

@@ -134,7 +134,7 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
Widget get _aboudItem => ListTile( Widget get _aboudItem => ListTile(
dense: true, dense: true,
title: Text('关于 SponsorBlock', style: _titleStyle), title: Text('关于空降助手', style: _titleStyle),
subtitle: Text(_url, style: _subTitleStyle), subtitle: Text(_url, style: _subTitleStyle),
onTap: () => Utils.launchURL(_url), onTap: () => Utils.launchURL(_url),
); );
@@ -248,9 +248,14 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
dense: true, dense: true,
onTap: _updateBlockTrack, onTap: _updateBlockTrack,
title: Text( title: Text(
'记录跳过片段', '跳过次数统计跟踪',
style: _titleStyle, style: _titleStyle,
), ),
subtitle: Text(
// from origin extension
'此功能追踪您跳过了哪些片段,让用户知道他们提交的片段帮助了多少人。同时点赞会作为依据,确保垃圾信息不会污染数据库。在您每次跳过片段时,我们都会向服务器发送一条消息。希望大家开启此项设置,以便得到更准确的统计数据。:)',
style: _subTitleStyle,
),
trailing: Transform.scale( trailing: Transform.scale(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
scale: 0.8, scale: 0.8,
@@ -368,7 +373,7 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: Text('Sponsor Block')), appBar: AppBar(title: Text('空降助手')),
body: CustomScrollView( body: CustomScrollView(
slivers: [ slivers: [
_dividerL, _dividerL,

View File

@@ -133,6 +133,10 @@ class PostSegmentModel {
enum ActionType { skip, mute, full, poi } enum ActionType { skip, mute, full, poi }
extension ActionTypeExt on ActionType {
String get title => ['跳过', '静音', '整个视频', '精彩时刻'][index];
}
class VideoDetailController extends GetxController class VideoDetailController extends GetxController
with GetSingleTickerProviderStateMixin { with GetSingleTickerProviderStateMixin {
/// 路由传参 /// 路由传参
@@ -1234,9 +1238,11 @@ class VideoDetailController extends GetxController
PopupMenuButton( PopupMenuButton(
initialValue: list![index].category, initialValue: list![index].category,
onSelected: (item) async { onSelected: (item) async {
setState(() { list![index].category = item;
list![index].category = item; list![index].actionType =
}); _segmentType2ActionType(item)
.first;
setState(() {});
}, },
itemBuilder: (context) => itemBuilder: (context) =>
SegmentType.values SegmentType.values
@@ -1273,7 +1279,7 @@ class VideoDetailController extends GetxController
), ),
), ),
const SizedBox(width: 16), const SizedBox(width: 16),
const Text('ActionType: '), const Text('行为类别: '),
PopupMenuButton( PopupMenuButton(
initialValue: initialValue:
list![index].actionType, list![index].actionType,
@@ -1284,11 +1290,18 @@ class VideoDetailController extends GetxController
}, },
itemBuilder: (context) => ActionType itemBuilder: (context) => ActionType
.values .values
.map((item) => .map(
PopupMenuItem<ActionType>( (item) =>
value: item, PopupMenuItem<ActionType>(
child: Text(item.name), enabled:
)) _segmentType2ActionType(
list![index]
.category)
.contains(item),
value: item,
child: Text(item.title),
),
)
.toList(), .toList(),
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@@ -1296,7 +1309,7 @@ class VideoDetailController extends GetxController
CrossAxisAlignment.start, CrossAxisAlignment.start,
children: [ children: [
Text( Text(
list![index].actionType.name, list![index].actionType.title,
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
color: Theme.of(context) color: Theme.of(context)
@@ -1369,6 +1382,9 @@ class VideoDetailController extends GetxController
_handleSBData(res); _handleSBData(res);
plPlayerController.segmentList.value = plPlayerController.segmentList.value =
_segmentProgressList ?? <Segment>[]; _segmentProgressList ?? <Segment>[];
if (positionSubscription == null) {
_initSkip();
}
} else { } else {
SmartDialog.showToast( SmartDialog.showToast(
'提交失败: ${{ '提交失败: ${{
@@ -1392,4 +1408,76 @@ class VideoDetailController extends GetxController
); );
}, },
); );
List<SegmentType> _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<ActionType> _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],
};
}
} }