Skip to content

Commit

Permalink
Merge branch 'master' into custom-lg
Browse files Browse the repository at this point in the history
* master:
  chewie, version 1.7.4. Addresses fluttercommunity#757.
  chewie, version 1.7.3. Addresses fluttercommunity#777.
  Added comments and optimised code
  fix display size while Chewie wrapped by some rotate widget
  Lint issue Fixed
  Revert "Update cupertino_controls.dart"
  Update cupertino_controls.dart
  Fixed : Playback speed reset on forwarding video

# Conflicts:
#	lib/src/player_with_controls.dart
  • Loading branch information
lg8294 committed Dec 6, 2023
2 parents c8f733e + d9cee39 commit 126bd35
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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).

Expand Down
22 changes: 17 additions & 5 deletions lib/src/cupertino/cupertino_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class _CupertinoControlsState extends State<CupertinoControls>
bool _subtitleOn = false;
Timer? _bufferingDisplayTimer;
bool _displayBufferingIndicator = false;

double selectedSpeed = 1.0;
late VideoPlayerController controller;

// We know that _chewieController is set in didChangeDependencies
Expand Down Expand Up @@ -559,6 +559,8 @@ class _CupertinoControlsState extends State<CupertinoControls>

if (chosenSpeed != null) {
controller.setPlaybackSpeed(chosenSpeed);

selectedSpeed = chosenSpeed;
}

if (_latestValue.isPlaying) {
Expand Down Expand Up @@ -748,20 +750,30 @@ class _CupertinoControlsState extends State<CupertinoControls>
});
}

void _skipBack() {
Future<void> _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<void> _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() {
Expand Down
21 changes: 12 additions & 9 deletions lib/src/player_with_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
// ),
// ),
// ),
// );
// );
// });
}
}
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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'
Expand Down

0 comments on commit 126bd35

Please sign in to comment.