Skip to content

Added seek forward and rewind buttons - #717

Open
punit1111 wants to merge 7 commits into
fluttercommunity:masterfrom
punit1111:master
Open

punit1111 wants to merge 7 commits into
fluttercommunity:masterfrom
punit1111:master

Conversation

@punit1111

@punit1111 punit1111 commented Mar 28, 2023 •

Copy link
Copy Markdown
  • double tap or click to seek forward or rewind back 10 seconds
  • seek forward and rewind buttons added to video controls screen
    are there other controls? #715

@diegotori

Copy link
Copy Markdown
Collaborator

@punit1111 Thank you for your PR.

Please re-sync your changes with the latest changes in master.

@punit1111

punit1111 commented Jul 3, 2023 •

Copy link
Copy Markdown
Author

@punit1111 Thank you for your PR.

Please re-sync your changes with the latest changes in master.

@diegotori re-sync done please review the PR

Thank you

Comment thread lib/src/cupertino/cupertino_controls.dart Outdated
Comment thread lib/src/cupertino/cupertino_controls.dart Outdated
Comment thread lib/src/material/material_controls.dart Outdated
@punit1111

Copy link
Copy Markdown
Author

@maherjaafar requested changes are done. please review the PR

Thank you

@punit1111
punit1111 requested a review from maherjaafar July 5, 2023 05:33
Comment thread lib/src/hit_area_controls.dart Outdated
Comment on lines +54 to +63
SeekRewindButton _buildSeekRewindButton({bool isSeekForward = true}) {
return SeekRewindButton(
backgroundColor: backgroundColor,
iconColor: iconColor,
show: showSeekButton,
onPressed: isSeekForward ? seekForward : seekRewind,
onDoublePressed: isSeekForward ? seekForward : seekRewind,
icon: isSeekForward ? Icons.fast_forward : Icons.fast_rewind,
);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use methods to return widgets. Instead you can simply add SeekRewindButton as part of your Row children.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

earlier it was inside a Row children. it's extracted into method as changes requested #717 (comment)

@diegotori diegotori Aug 2, 2023 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maherjaafar just an FYI, according to this issue and the official documentation regarding this subject, large Widgets should be spun off into new ones instead of methods that return them.

That way, you'll be able to create them as consts, thus increasing performance since they won't have to be re-built when build is called again.

@punit1111 sorry for the extra work, but these widgets should ultimately be extracted as new StatelessWidgets instead of being computed from a method.

Please let me know if this clears up things.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diegotori SeekRewindButton is already extracted as Stateless Widget lib/src/seek_rewind_button.dart

@diegotori diegotori Aug 4, 2023 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@punit1111 that is true, but instead of creating it from _buildSeekRewindButton, you should just replace those calls with the actual widget:

Change this:

_buildSeekRewindButton(isSeekForward: true),

to this:

SeekRewindButton(
      backgroundColor: backgroundColor,
      iconColor: iconColor,
      show: showSeekButton,
      onPressed: seekForward,
      onDoublePressed: seekForward,
      icon: Icons.fast_forward,
    )

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do likewise for the other places where that method is being called from.

Comment thread lib/src/seek_rewind_button.dart Outdated
@@ -0,0 +1,61 @@
import 'package:flutter/material.dart';

class SeekRewindButton extends StatefulWidget {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be renamed to SeekControlButton, so that it better reflects its stated purpose.

That way, you can create buttons that just configure that widget for its specific purpose:

class SeekRewindButton extends StatefulWidget {
   const SeekRewindButton({
     super.key,
    required this.backgroundColor,
    this.iconColor,
    required this.show,
    this.onPressed,
    this.onDoublePressed,
    this.icon = const Icons.fast_rewind,
   });
   
  final Color backgroundColor;
  final Color? iconColor;
  final bool show;
  final VoidCallback? onPressed;
  final VoidCallback? onDoublePressed;
  final IconData icon;
   
   Widget build(BuildContext context) {
     return SeekControlButton(
       backgroundColor: backgroundColor,
       iconColor: iconColor,
       show: show,
       icon: icon,
       onPressed: onPressed,
       onDoublePressed: onDoublePressed,
     );
   }
}

Do likewise for the fast-forward button: (i.e. SeekFastForwardButton).

Comment thread lib/src/seek_rewind_button.dart Outdated
final bool show;
final VoidCallback? onPressed;
final VoidCallback? onDoublePressed;
final IconData? icon;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If required, make it non-nullable.

@punit1111
punit1111 requested a review from diegotori August 5, 2023 06:20
@punit1111

Copy link
Copy Markdown
Author

Hi @diegotori

please review the Changes and let me know if anything needs to be fixed

Thank you

Comment on lines -363 to -370
child: CenterPlayButton(
backgroundColor: widget.backgroundColor,
iconColor: widget.iconColor,
isFinished: isFinished,
isPlaying: controller.value.isPlaying,
show: showPlayButton,
onPressed: _playPause,
),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cupertino controls already have the seek-forward and rewind buttons in the seek bar (i.e. the ones that rewind and fast-forward by 15 seconds).

As a result, this change should only apply to Material based widgets.

Do this for the other new widgets added in this PR, since they should only apply to Material.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @diegotori

requested changes done please review

Thank you

@punit1111
punit1111 requested a review from diegotori August 25, 2023 13:04

@diegotori diegotori left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@diegotori

Copy link
Copy Markdown
Collaborator

@maherjaafar please give this PR one last look before I can finalize this change.

Thanks.

@ameya730

Copy link
Copy Markdown

Hi,
Any update on when this branch will be pushed.
Regards,
Ameya

@maherjaafar maherjaafar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Ortes

Ortes commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Thanks @punit1111 — this PR pioneered double-tap-to-seek for chewie. For context on why it stalled: #703 shipped the center seek buttons in Sep 2024 (this PR was approved again two days after that, which is how the overlap got missed), and master has since diverged past the HitAreaControls refactor here (3-way conflicts).

The parts master still lacks — double-tap left/right zones with an accumulating indicator — are now implemented in #964 (stacked on #953), with credit to this PR. Suggest the maintainers close this one as superseded by #703 + #964.

Ortes added a commit to Fullphysio/chewie that referenced this pull request Sep 1, 2026
Mobile (MaterialControls):
- Double-tapping the left/right side of the video seeks backward/forward,
  flashing the accumulating seek indicator. The middle band is a dead zone.
- While the indicator is visible, further single taps in the same zone keep
  seeking (10s -> 20s -> 30s), like YouTube.
- Gated by ChewieController.allowDoubleTapSeek (default true) with the step
  set by ChewieController.doubleTapSeekDuration (default 10s). Disabled on
  live streams and when playback is finished.

Desktop (MaterialDesktopControls):
- Double-clicking the video toggles fullscreen, like the YouTube desktop
  player. Gated by ChewieController.allowDoubleTapToggleFullScreen (default
  true) and allowFullScreen.

The keyboard seek indicator state introduced by fluttercommunity#953 moves from
_MaterialDesktopControlsState into a shared SeekIndicatorStateMixin so both
control sets drive the same SeekIndicator.

Double-tap-to-seek was first explored by punit1111 in fluttercommunity#717.
Ortes added a commit to Fullphysio/chewie that referenced this pull request Sep 1, 2026
Mobile (MaterialControls):
- Double-tapping the left/right side of the video seeks backward/forward,
  flashing the accumulating seek indicator. The middle band is a dead zone.
- While the indicator is visible, further single taps in the same zone keep
  seeking (10s -> 20s -> 30s), like YouTube.
- Gated by ChewieController.allowDoubleTapSeek (default true) with the step
  set by ChewieController.doubleTapSeekDuration (default 10s). Disabled on
  live streams and when playback is finished.

Desktop (MaterialDesktopControls):
- Double-clicking the video toggles fullscreen, like the YouTube desktop
  player. Gated by ChewieController.allowDoubleTapToggleFullScreen (default
  true) and allowFullScreen.

The keyboard seek indicator state introduced by fluttercommunity#953 moves from
_MaterialDesktopControlsState into a shared SeekIndicatorStateMixin so both
control sets drive the same SeekIndicator.

Double-tap-to-seek was first explored by punit1111 in fluttercommunity#717.
Ortes added a commit to Fullphysio/chewie that referenced this pull request Sep 9, 2026
Mobile (MaterialControls):
- Double-tapping the left/right side of the video seeks backward/forward,
  flashing the accumulating seek indicator. The middle band is a dead zone.
- While the indicator is visible, further single taps in the same zone keep
  seeking (10s -> 20s -> 30s), like YouTube.
- Gated by ChewieController.allowDoubleTapSeek (default true) with the step
  set by ChewieController.doubleTapSeekDuration (default 10s). Disabled on
  live streams and when playback is finished.

Desktop (MaterialDesktopControls):
- Double-clicking the video toggles fullscreen, like the YouTube desktop
  player. Gated by ChewieController.allowDoubleTapToggleFullScreen (default
  true) and allowFullScreen.

The keyboard seek indicator state introduced by fluttercommunity#953 moves from
_MaterialDesktopControlsState into a shared SeekIndicatorStateMixin so both
control sets drive the same SeekIndicator.

Double-tap-to-seek was first explored by punit1111 in fluttercommunity#717.
Ortes added a commit to Fullphysio/chewie that referenced this pull request Sep 14, 2026
Mobile (MaterialControls):
- Double-tapping the left/right side of the video seeks backward/forward,
  flashing the accumulating seek indicator. The middle band is a dead zone.
- While the indicator is visible, further single taps in the same zone keep
  seeking (10s -> 20s -> 30s), like YouTube.
- Gated by ChewieController.allowDoubleTapSeek (default true) with the step
  set by ChewieController.doubleTapSeekDuration (default 10s). Disabled on
  live streams and when playback is finished.

Desktop (MaterialDesktopControls):
- Double-clicking the video toggles fullscreen, like the YouTube desktop
  player. Gated by ChewieController.allowDoubleTapToggleFullScreen (default
  true) and allowFullScreen.

The keyboard seek indicator state introduced by fluttercommunity#953 moves from
_MaterialDesktopControlsState into a shared SeekIndicatorStateMixin so both
control sets drive the same SeekIndicator.

Double-tap-to-seek was first explored by punit1111 in fluttercommunity#717.
Ortes added a commit to Fullphysio/chewie that referenced this pull request Sep 14, 2026
Mobile (MaterialControls):
- Double-tapping the left/right side of the video seeks backward/forward,
  flashing the accumulating seek indicator. The middle band is a dead zone.
- While the indicator is visible, further single taps in the same zone keep
  seeking (10s -> 20s -> 30s), like YouTube.
- Gated by ChewieController.allowDoubleTapSeek (default true) with the step
  set by ChewieController.doubleTapSeekDuration (default 10s). Disabled on
  live streams and when playback is finished.

Desktop (MaterialDesktopControls):
- Double-clicking the video toggles fullscreen, like the YouTube desktop
  player. Gated by ChewieController.allowDoubleTapToggleFullScreen (default
  true) and allowFullScreen.

The keyboard seek indicator state introduced by fluttercommunity#953 moves from
_MaterialDesktopControlsState into a shared SeekIndicatorStateMixin so both
control sets drive the same SeekIndicator.

Double-tap-to-seek was first explored by punit1111 in fluttercommunity#717.
Ortes added a commit to Fullphysio/chewie that referenced this pull request Sep 15, 2026
Mobile (MaterialControls):
- Double-tapping the left/right side of the video seeks backward/forward,
  flashing the accumulating seek indicator. The middle band is a dead zone.
- While the indicator is visible, further single taps in the same zone keep
  seeking (10s -> 20s -> 30s), like YouTube.
- Gated by ChewieController.allowDoubleTapSeek (default true) with the step
  set by ChewieController.doubleTapSeekDuration (default 10s). Disabled on
  live streams and when playback is finished.

Desktop (MaterialDesktopControls):
- Double-clicking the video toggles fullscreen, like the YouTube desktop
  player. Gated by ChewieController.allowDoubleTapToggleFullScreen (default
  true) and allowFullScreen.

The keyboard seek indicator state introduced by fluttercommunity#953 moves from
_MaterialDesktopControlsState into a shared SeekIndicatorStateMixin so both
control sets drive the same SeekIndicator.

Double-tap-to-seek was first explored by punit1111 in fluttercommunity#717.
Ortes added a commit to Fullphysio/chewie that referenced this pull request Sep 16, 2026
Mobile (MaterialControls):
- Double-tapping the left/right side of the video seeks backward/forward,
  flashing the accumulating seek indicator. The middle band is a dead zone.
- While the indicator is visible, further single taps in the same zone keep
  seeking (10s -> 20s -> 30s), like YouTube.
- Gated by ChewieController.allowDoubleTapSeek (default true) with the step
  set by ChewieController.doubleTapSeekDuration (default 10s). Disabled on
  live streams and when playback is finished.

Desktop (MaterialDesktopControls):
- Double-clicking the video toggles fullscreen, like the YouTube desktop
  player. Gated by ChewieController.allowDoubleTapToggleFullScreen (default
  true) and allowFullScreen.

The keyboard seek indicator state introduced by fluttercommunity#953 moves from
_MaterialDesktopControlsState into a shared SeekIndicatorStateMixin so both
control sets drive the same SeekIndicator.

Double-tap-to-seek was first explored by punit1111 in fluttercommunity#717.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants