Skip to content

Commit

Permalink
chore: instant video controls showing
Browse files Browse the repository at this point in the history
double tap to seek is detected only after second tap, instead of waiting
  • Loading branch information
MSOB7YY committed Feb 18, 2024
1 parent 7a614c8 commit a6a3ebd
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions lib/ui/widgets/video_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -635,25 +635,23 @@ class NamidaVideoControlsState extends State<NamidaVideoControls> with TickerPro
onTapUp: _canShowControls
? (event) {
if (_isDraggingSeekBar) return;
final screenPart = context.width / 3;
final dx = event.localPosition.dx;
if (dx >= screenPart && dx <= screenPart * 2) {
// pressed in middle
_onTap();
_onFinishingDoubleTapTimer();
} else {
if (_doubleTapFirstPress) {
_onDoubleTap(event.localPosition);

if (_doubleTapFirstPress && _doubleTapTimer?.isActive == true) {
// -- pressed again within 200ms.
_onDoubleTap(event.localPosition);
setControlsVisibily(false);
_doubleTapTimer?.cancel();
_doubleTapTimer = Timer(const Duration(milliseconds: 200), () {
_doubleTapFirstPress = false;
_onFinishingDoubleTapTimer();
} else {
_doubleTapFirstPress = true;
_doubleTapTimer ??= Timer(const Duration(milliseconds: 200), () {
if (_doubleTapFirstPress) {
_onTap();
_onFinishingDoubleTapTimer();
}
});
}
});
} else {
_onTap();
_doubleTapFirstPress = true;
_doubleTapTimer?.cancel();
_doubleTapTimer = Timer(const Duration(milliseconds: 200), () {
_doubleTapFirstPress = false;
});
}
}
: null,
Expand Down

0 comments on commit a6a3ebd

Please sign in to comment.