Skip to content

Commit a3d1ce5

Browse files
authored
Merge pull request #617 from jmsanc/master
Allow video zooming with InteractiveViewer widget.
2 parents b131d69 + 305e44c commit a3d1ce5

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed

lib/src/chewie_player.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ class ChewieController extends ChangeNotifier {
262262
this.optionsBuilder,
263263
this.additionalOptions,
264264
this.showControls = true,
265+
this.zoomAndPan = false,
266+
this.maxScale = 2.5,
265267
this.subtitle,
266268
this.subtitleBuilder,
267269
this.customControls,
@@ -303,6 +305,8 @@ class ChewieController extends ChangeNotifier {
303305
Future<void> Function(BuildContext, List<OptionItem>)? optionsBuilder,
304306
List<OptionItem> Function(BuildContext)? additionalOptions,
305307
bool? showControls,
308+
bool? zoomAndPan,
309+
double? maxScale,
306310
Subtitles? subtitle,
307311
Widget Function(BuildContext, dynamic)? subtitleBuilder,
308312
Widget? customControls,
@@ -426,6 +430,12 @@ class ChewieController extends ChangeNotifier {
426430
/// Whether or not to show the controls at all
427431
final bool showControls;
428432

433+
/// Whether or not to allow zooming and panning
434+
final bool zoomAndPan;
435+
436+
/// Max scale when zooming
437+
final double maxScale;
438+
429439
/// Defines customised controls. Check [MaterialControls] or
430440
/// [CupertinoControls] for reference.
431441
final Widget? customControls;

lib/src/player_with_controls.dart

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@ class PlayerWithControls extends StatelessWidget {
3737
children: <Widget>[
3838
if (chewieController.placeholder != null)
3939
chewieController.placeholder!,
40-
Center(
41-
child: AspectRatio(
42-
aspectRatio: chewieController.aspectRatio ??
43-
chewieController.videoPlayerController.value.aspectRatio,
44-
child: VideoPlayer(chewieController.videoPlayerController),
40+
InteractiveViewer(
41+
maxScale: chewieController.maxScale,
42+
panEnabled: chewieController.zoomAndPan,
43+
scaleEnabled: chewieController.zoomAndPan,
44+
child: Center(
45+
child: AspectRatio(
46+
aspectRatio: chewieController.aspectRatio ??
47+
chewieController.videoPlayerController.value.aspectRatio,
48+
child: VideoPlayer(chewieController.videoPlayerController),
49+
),
4550
),
4651
),
4752
if (chewieController.overlay != null) chewieController.overlay!,
@@ -52,14 +57,17 @@ class PlayerWithControls extends StatelessWidget {
5257
PlayerNotifier notifier,
5358
Widget? widget,
5459
) =>
55-
AnimatedOpacity(
56-
opacity: notifier.hideStuff ? 0.0 : 0.8,
57-
duration: const Duration(
58-
milliseconds: 250,
59-
),
60-
child: Container(
61-
decoration: const BoxDecoration(color: Colors.black54),
62-
child: Container(),
60+
Visibility(
61+
visible: !notifier.hideStuff,
62+
child: AnimatedOpacity(
63+
opacity: notifier.hideStuff ? 0.0 : 0.8,
64+
duration: const Duration(
65+
milliseconds: 250,
66+
),
67+
child: Container(
68+
decoration: const BoxDecoration(color: Colors.black54),
69+
child: Container(),
70+
),
6371
),
6472
),
6573
),

0 commit comments

Comments
 (0)