Skip to content

Fix zoomAndPan not having an effect #920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (keystorePropertiesFile.exists()) {

android {
namespace "com.example.example"
compileSdk 34
compileSdk 35

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
Expand Down
1 change: 1 addition & 0 deletions example/lib/app/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class _ChewieDemoState extends State<ChewieDemo> {
_chewieController = ChewieController(
videoPlayerController: _videoPlayerController1,
autoPlay: true,
zoomAndPan: true,
looping: true,
progressIndicatorDelay:
bufferDelay != null ? Duration(milliseconds: bufferDelay!) : null,
Expand Down
6 changes: 6 additions & 0 deletions lib/src/chewie_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,12 @@
cupertinoProgressColors ?? this.cupertinoProgressColors,
materialProgressColors:
materialProgressColors ?? this.materialProgressColors,
zoomAndPan: zoomAndPan ?? this.zoomAndPan,
maxScale: maxScale ?? this.maxScale,

Check warning on line 387 in lib/src/chewie_player.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/chewie_player.dart#L386-L387

Added lines #L386 - L387 were not covered by tests
controlsSafeAreaMinimum:
controlsSafeAreaMinimum ?? this.controlsSafeAreaMinimum,

Check warning on line 389 in lib/src/chewie_player.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/chewie_player.dart#L389

Added line #L389 was not covered by tests
transformationController:
transformationController ?? this.transformationController,

Check warning on line 391 in lib/src/chewie_player.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/chewie_player.dart#L391

Added line #L391 was not covered by tests
materialSeekButtonFadeDuration:
materialSeekButtonFadeDuration ?? this.materialSeekButtonFadeDuration,
materialSeekButtonSize:
Expand Down
84 changes: 46 additions & 38 deletions lib/src/player_with_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,53 +33,61 @@
ChewieController chewieController,
BuildContext context,
) {
return Stack(
children: <Widget>[
if (chewieController.placeholder != null)
chewieController.placeholder!,
InteractiveViewer(
transformationController: chewieController.transformationController,
maxScale: chewieController.maxScale,
panEnabled: chewieController.zoomAndPan,
scaleEnabled: chewieController.zoomAndPan,
child: Center(
final playerNotifier =
Provider.of<PlayerNotifier>(context, listen: false);
return InteractiveViewer(
transformationController: chewieController.transformationController,
maxScale: chewieController.maxScale,
panEnabled: chewieController.zoomAndPan,
scaleEnabled: chewieController.zoomAndPan,
onInteractionUpdate: chewieController.zoomAndPan
? (_) => playerNotifier.hideStuff = true

Check warning on line 44 in lib/src/player_with_controls.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/player_with_controls.dart#L44

Added line #L44 was not covered by tests
: null,
onInteractionEnd: chewieController.zoomAndPan
? (_) => playerNotifier.hideStuff = false

Check warning on line 47 in lib/src/player_with_controls.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/player_with_controls.dart#L47

Added line #L47 was not covered by tests
: null,
child: Stack(
children: [
if (chewieController.placeholder != null)
chewieController.placeholder!,

Check warning on line 52 in lib/src/player_with_controls.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/player_with_controls.dart#L52

Added line #L52 was not covered by tests
Center(
child: AspectRatio(
aspectRatio: chewieController.aspectRatio ??
chewieController.videoPlayerController.value.aspectRatio,
child: VideoPlayer(chewieController.videoPlayerController),
),
),
),
if (chewieController.overlay != null) chewieController.overlay!,
if (Theme.of(context).platform != TargetPlatform.iOS)
Consumer<PlayerNotifier>(
builder: (
BuildContext context,
PlayerNotifier notifier,
Widget? widget,
) =>
Visibility(
visible: !notifier.hideStuff,
child: AnimatedOpacity(
opacity: notifier.hideStuff ? 0.0 : 0.8,
duration: const Duration(
milliseconds: 250,
),
child: const DecoratedBox(
decoration: BoxDecoration(color: Colors.black54),
child: SizedBox.expand(),
if (chewieController.overlay != null) chewieController.overlay!,
if (Theme.of(context).platform != TargetPlatform.iOS)
Consumer<PlayerNotifier>(
builder: (
BuildContext context,
PlayerNotifier notifier,
Widget? widget,
) =>
Visibility(
visible: !notifier.hideStuff,
child: AnimatedOpacity(
opacity: notifier.hideStuff ? 0.0 : 0.8,
duration: const Duration(
milliseconds: 250,
),
child: const DecoratedBox(
decoration: BoxDecoration(color: Colors.black54),
child: SizedBox.expand(),
),
),
),
),
),
if (!chewieController.isFullScreen)
buildControls(context, chewieController)
else
SafeArea(
bottom: false,
child: buildControls(context, chewieController),
),
],
if (!chewieController.isFullScreen)
buildControls(context, chewieController)
else
SafeArea(

Check warning on line 85 in lib/src/player_with_controls.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/player_with_controls.dart#L85

Added line #L85 was not covered by tests
bottom: false,
child: buildControls(context, chewieController),

Check warning on line 87 in lib/src/player_with_controls.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/player_with_controls.dart#L87

Added line #L87 was not covered by tests
),
],
),
);
}

Expand Down