diff --git a/CHANGELOG.md b/CHANGELOG.md index 41f1e0780..fa40e61bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.7.4 +* 🛠️ [#774](https://github.com/fluttercommunity/chewie/pull/774): Fixed : Playback speed reset on forwarding video. Thanks [Kronos-2701](https://github.com/Kronos-2701). + +## 1.7.3 +* 🛠️ [#777](https://github.com/fluttercommunity/chewie/pull/777): fix display size while Chewie wrapped by some rotate widget. Thanks [bailyzheng](https://github.com/bailyzheng). + ## 1.7.2 * 🛠️ [#798](https://github.com/fluttercommunity/chewie/pull/798): Fix: Progress bar does not follow drag #789. Thanks [koutaro-masaki](https://github.com/koutaro-masaki). diff --git a/lib/src/cupertino/cupertino_controls.dart b/lib/src/cupertino/cupertino_controls.dart index 7e16b38a1..6fd319e43 100644 --- a/lib/src/cupertino/cupertino_controls.dart +++ b/lib/src/cupertino/cupertino_controls.dart @@ -49,7 +49,7 @@ class _CupertinoControlsState extends State bool _subtitleOn = false; Timer? _bufferingDisplayTimer; bool _displayBufferingIndicator = false; - + double selectedSpeed = 1.0; late VideoPlayerController controller; // We know that _chewieController is set in didChangeDependencies @@ -559,6 +559,8 @@ class _CupertinoControlsState extends State if (chosenSpeed != null) { controller.setPlaybackSpeed(chosenSpeed); + + selectedSpeed = chosenSpeed; } if (_latestValue.isPlaying) { @@ -748,20 +750,30 @@ class _CupertinoControlsState extends State }); } - void _skipBack() { + Future _skipBack() async { _cancelAndRestartTimer(); final beginning = Duration.zero.inMilliseconds; final skip = (_latestValue.position - const Duration(seconds: 15)).inMilliseconds; - controller.seekTo(Duration(milliseconds: math.max(skip, beginning))); + await controller.seekTo(Duration(milliseconds: math.max(skip, beginning))); + // Restoring the video speed to selected speed + // A delay of 1 second is added to ensure a smooth transition of speed after reversing the video as reversing is an asynchronous function + Future.delayed(const Duration(milliseconds: 1000), () { + controller.setPlaybackSpeed(selectedSpeed); + }); } - void _skipForward() { + Future _skipForward() async { _cancelAndRestartTimer(); final end = _latestValue.duration.inMilliseconds; final skip = (_latestValue.position + const Duration(seconds: 15)).inMilliseconds; - controller.seekTo(Duration(milliseconds: math.min(skip, end))); + await controller.seekTo(Duration(milliseconds: math.min(skip, end))); + // Restoring the video speed to selected speed + // A delay of 1 second is added to ensure a smooth transition of speed after forwarding the video as forwaring is an asynchronous function + Future.delayed(const Duration(milliseconds: 1000), () { + controller.setPlaybackSpeed(selectedSpeed); + }); } void _startHideTimer() { diff --git a/lib/src/player_with_controls.dart b/lib/src/player_with_controls.dart index 282aebf1e..a6294bcc0 100644 --- a/lib/src/player_with_controls.dart +++ b/lib/src/player_with_controls.dart @@ -95,15 +95,18 @@ class PlayerWithControls extends StatelessWidget { child: buildPlayerWithControls(chewieController, context), ); - // return Center( - // child: SizedBox( - // height: MediaQuery.of(context).size.height, - // width: MediaQuery.of(context).size.width, - // child: AspectRatio( - // aspectRatio: calculateAspectRatio(context), - // child: buildPlayerWithControls(chewieController, context), + // return LayoutBuilder( + // builder: (BuildContext context, BoxConstraints constraints) { + // return Center( + // child: SizedBox( + // height: constraints.maxHeight, + // width: constraints.maxWidth, + // child: AspectRatio( + // aspectRatio: calculateAspectRatio(context), + // child: buildPlayerWithControls(chewieController, context), + // ), // ), - // ), - // ); + // ); + // }); } } diff --git a/pubspec.yaml b/pubspec.yaml index 8134442cb..120c91f40 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: chewie description: A video player for Flutter with Cupertino and Material play controls -version: 1.7.2 -homepage: https://github.com/fluttercommunity/chewie +version: 1.7.4 +homepage: http://github.com/fluttercommunity/chewie environment: sdk: '>=2.18.0 <4.0.0'