mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
skip segments with keyboard
Closes #1379 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -843,6 +843,11 @@ class VideoDetailController extends GetxController
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cancelSkipTimer() {
|
||||||
|
skipTimer?.cancel();
|
||||||
|
skipTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
void onRemoveItem(int index, item) {
|
void onRemoveItem(int index, item) {
|
||||||
EasyThrottle.throttle(
|
EasyThrottle.throttle(
|
||||||
'onRemoveItem',
|
'onRemoveItem',
|
||||||
@@ -851,8 +856,7 @@ class VideoDetailController extends GetxController
|
|||||||
try {
|
try {
|
||||||
listData.removeAt(index);
|
listData.removeAt(index);
|
||||||
if (listData.isEmpty) {
|
if (listData.isEmpty) {
|
||||||
skipTimer?.cancel();
|
cancelSkipTimer();
|
||||||
skipTimer = null;
|
|
||||||
}
|
}
|
||||||
listKey.currentState?.removeItem(
|
listKey.currentState?.removeItem(
|
||||||
index,
|
index,
|
||||||
@@ -1689,4 +1693,19 @@ class VideoDetailController extends GetxController
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool onSkipSegment() {
|
||||||
|
try {
|
||||||
|
if (plPlayerController.enableSponsorBlock) {
|
||||||
|
if (listData.lastOrNull case SegmentModel item) {
|
||||||
|
onSkip(item);
|
||||||
|
onRemoveItem(listData.indexOf(item), item);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (_) {
|
||||||
|
if (kDebugMode) rethrow;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -323,8 +323,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
..removePositionListener(positionListener);
|
..removePositionListener(positionListener);
|
||||||
|
|
||||||
videoDetailController
|
videoDetailController
|
||||||
..skipTimer?.cancel()
|
..cancelSkipTimer()
|
||||||
..skipTimer = null
|
|
||||||
..positionSubscription?.cancel()
|
..positionSubscription?.cancel()
|
||||||
..cid.close()
|
..cid.close()
|
||||||
..animController?.removeListener(animListener);
|
..animController?.removeListener(animListener);
|
||||||
@@ -1492,6 +1491,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
handlePlay();
|
handlePlay();
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
onSkipSegment: videoDetailController.onSkipSegment,
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1722,13 +1722,16 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
// videoDetailController.onAddItem(
|
// videoDetailController.onAddItem(
|
||||||
// SegmentModel(
|
// SegmentModel(
|
||||||
// UUID: '',
|
// UUID: '',
|
||||||
// segmentType: SegmentType.sponsor,
|
// segmentType:
|
||||||
|
// SegmentType.values[Utils.random.nextInt(
|
||||||
|
// SegmentType.values.length,
|
||||||
|
// )],
|
||||||
// segment: Pair(first: 0, second: 0),
|
// segment: Pair(first: 0, second: 0),
|
||||||
// skipType: SkipType.alwaysSkip,
|
// skipType: SkipType.alwaysSkip,
|
||||||
// ),
|
// ),
|
||||||
// );
|
// );
|
||||||
// },
|
// },
|
||||||
// child: Text('skip'),
|
// child: const Text('skip'),
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// Positioned(
|
// Positioned(
|
||||||
@@ -1738,7 +1741,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
|||||||
// onPressed: () {
|
// onPressed: () {
|
||||||
// videoDetailController.onAddItem(2);
|
// videoDetailController.onAddItem(2);
|
||||||
// },
|
// },
|
||||||
// child: Text('index'),
|
// child: const Text('index'),
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
Obx(
|
Obx(
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class PlayerFocus extends StatelessWidget {
|
|||||||
this.introController,
|
this.introController,
|
||||||
required this.onSendDanmaku,
|
required this.onSendDanmaku,
|
||||||
this.canPlay,
|
this.canPlay,
|
||||||
|
this.onSkipSegment,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
@@ -28,6 +29,7 @@ class PlayerFocus extends StatelessWidget {
|
|||||||
final CommonIntroController? introController;
|
final CommonIntroController? introController;
|
||||||
final VoidCallback onSendDanmaku;
|
final VoidCallback onSendDanmaku;
|
||||||
final bool Function()? canPlay;
|
final bool Function()? canPlay;
|
||||||
|
final bool Function()? onSkipSegment;
|
||||||
|
|
||||||
static bool _shouldHandle(LogicalKeyboardKey logicalKey) {
|
static bool _shouldHandle(LogicalKeyboardKey logicalKey) {
|
||||||
return logicalKey == LogicalKeyboardKey.tab ||
|
return logicalKey == LogicalKeyboardKey.tab ||
|
||||||
@@ -209,6 +211,9 @@ class PlayerFocus extends StatelessWidget {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case LogicalKeyboardKey.enter:
|
case LogicalKeyboardKey.enter:
|
||||||
|
if (onSkipSegment?.call() ?? false) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
onSendDanmaku();
|
onSendDanmaku();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user