@@ -49,7 +49,7 @@ class _CupertinoControlsState extends State<CupertinoControls>
49
49
bool _subtitleOn = false ;
50
50
Timer ? _bufferingDisplayTimer;
51
51
bool _displayBufferingIndicator = false ;
52
-
52
+ double selectedSpeed = 1.0 ;
53
53
late VideoPlayerController controller;
54
54
55
55
// We know that _chewieController is set in didChangeDependencies
@@ -559,6 +559,8 @@ class _CupertinoControlsState extends State<CupertinoControls>
559
559
560
560
if (chosenSpeed != null ) {
561
561
controller.setPlaybackSpeed (chosenSpeed);
562
+
563
+ selectedSpeed = chosenSpeed;
562
564
}
563
565
564
566
if (_latestValue.isPlaying) {
@@ -748,20 +750,30 @@ class _CupertinoControlsState extends State<CupertinoControls>
748
750
});
749
751
}
750
752
751
- void _skipBack () {
753
+ Future < void > _skipBack () async {
752
754
_cancelAndRestartTimer ();
753
755
final beginning = Duration .zero.inMilliseconds;
754
756
final skip =
755
757
(_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
+ });
757
764
}
758
765
759
- void _skipForward () {
766
+ Future < void > _skipForward () async {
760
767
_cancelAndRestartTimer ();
761
768
final end = _latestValue.duration.inMilliseconds;
762
769
final skip =
763
770
(_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
+ });
765
777
}
766
778
767
779
void _startHideTimer () {
0 commit comments