@@ -49,7 +49,7 @@ class _CupertinoControlsState extends State<CupertinoControls>
4949 bool _subtitleOn = false ;
5050 Timer ? _bufferingDisplayTimer;
5151 bool _displayBufferingIndicator = false ;
52-
52+ double selectedSpeed = 1.0 ;
5353 late VideoPlayerController controller;
5454
5555 // We know that _chewieController is set in didChangeDependencies
@@ -559,6 +559,8 @@ class _CupertinoControlsState extends State<CupertinoControls>
559559
560560 if (chosenSpeed != null ) {
561561 controller.setPlaybackSpeed (chosenSpeed);
562+
563+ selectedSpeed = chosenSpeed;
562564 }
563565
564566 if (_latestValue.isPlaying) {
@@ -748,20 +750,30 @@ class _CupertinoControlsState extends State<CupertinoControls>
748750 });
749751 }
750752
751- void _skipBack () {
753+ Future < void > _skipBack () async {
752754 _cancelAndRestartTimer ();
753755 final beginning = Duration .zero.inMilliseconds;
754756 final skip =
755757 (_latestValue.position - const Duration (seconds: 15 )).inMilliseconds;
756- controller.seekTo (Duration (milliseconds: math.max (skip, beginning)));
758+ await controller.seekTo (Duration (milliseconds: math.max (skip, beginning)));
759+ // Restoring the video speed to selected speed
760+ // A delay of 1 second is added to ensure a smooth transition of speed after reversing the video as reversing is an asynchronous function
761+ Future .delayed (const Duration (milliseconds: 1000 ), () {
762+ controller.setPlaybackSpeed (selectedSpeed);
763+ });
757764 }
758765
759- void _skipForward () {
766+ Future < void > _skipForward () async {
760767 _cancelAndRestartTimer ();
761768 final end = _latestValue.duration.inMilliseconds;
762769 final skip =
763770 (_latestValue.position + const Duration (seconds: 15 )).inMilliseconds;
764- controller.seekTo (Duration (milliseconds: math.min (skip, end)));
771+ await controller.seekTo (Duration (milliseconds: math.min (skip, end)));
772+ // Restoring the video speed to selected speed
773+ // A delay of 1 second is added to ensure a smooth transition of speed after forwarding the video as forwaring is an asynchronous function
774+ Future .delayed (const Duration (milliseconds: 1000 ), () {
775+ controller.setPlaybackSpeed (selectedSpeed);
776+ });
765777 }
766778
767779 void _startHideTimer () {
0 commit comments