Skip to content

Commit

Permalink
Merge pull request #617 from jmsanc/master
Browse files Browse the repository at this point in the history
Allow video zooming with InteractiveViewer widget.
  • Loading branch information
diegotori authored Mar 11, 2022
2 parents b131d69 + 305e44c commit a3d1ce5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
10 changes: 10 additions & 0 deletions lib/src/chewie_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ class ChewieController extends ChangeNotifier {
this.optionsBuilder,
this.additionalOptions,
this.showControls = true,
this.zoomAndPan = false,
this.maxScale = 2.5,
this.subtitle,
this.subtitleBuilder,
this.customControls,
Expand Down Expand Up @@ -303,6 +305,8 @@ class ChewieController extends ChangeNotifier {
Future<void> Function(BuildContext, List<OptionItem>)? optionsBuilder,
List<OptionItem> Function(BuildContext)? additionalOptions,
bool? showControls,
bool? zoomAndPan,
double? maxScale,
Subtitles? subtitle,
Widget Function(BuildContext, dynamic)? subtitleBuilder,
Widget? customControls,
Expand Down Expand Up @@ -426,6 +430,12 @@ class ChewieController extends ChangeNotifier {
/// Whether or not to show the controls at all
final bool showControls;

/// Whether or not to allow zooming and panning
final bool zoomAndPan;

/// Max scale when zooming
final double maxScale;

/// Defines customised controls. Check [MaterialControls] or
/// [CupertinoControls] for reference.
final Widget? customControls;
Expand Down
34 changes: 21 additions & 13 deletions lib/src/player_with_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ class PlayerWithControls extends StatelessWidget {
children: <Widget>[
if (chewieController.placeholder != null)
chewieController.placeholder!,
Center(
child: AspectRatio(
aspectRatio: chewieController.aspectRatio ??
chewieController.videoPlayerController.value.aspectRatio,
child: VideoPlayer(chewieController.videoPlayerController),
InteractiveViewer(
maxScale: chewieController.maxScale,
panEnabled: chewieController.zoomAndPan,
scaleEnabled: chewieController.zoomAndPan,
child: Center(
child: AspectRatio(
aspectRatio: chewieController.aspectRatio ??
chewieController.videoPlayerController.value.aspectRatio,
child: VideoPlayer(chewieController.videoPlayerController),
),
),
),
if (chewieController.overlay != null) chewieController.overlay!,
Expand All @@ -52,14 +57,17 @@ class PlayerWithControls extends StatelessWidget {
PlayerNotifier notifier,
Widget? widget,
) =>
AnimatedOpacity(
opacity: notifier.hideStuff ? 0.0 : 0.8,
duration: const Duration(
milliseconds: 250,
),
child: Container(
decoration: const BoxDecoration(color: Colors.black54),
child: Container(),
Visibility(
visible: !notifier.hideStuff,
child: AnimatedOpacity(
opacity: notifier.hideStuff ? 0.0 : 0.8,
duration: const Duration(
milliseconds: 250,
),
child: Container(
decoration: const BoxDecoration(color: Colors.black54),
child: Container(),
),
),
),
),
Expand Down

0 comments on commit a3d1ce5

Please sign in to comment.