Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 12 additions & 2 deletions lib/src/chewie_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,12 @@ class ChewieController extends ChangeNotifier {
cupertinoProgressColors ?? this.cupertinoProgressColors,
materialProgressColors:
materialProgressColors ?? this.materialProgressColors,
zoomAndPan: zoomAndPan ?? this.zoomAndPan,
maxScale: maxScale ?? this.maxScale,
controlsSafeAreaMinimum:
controlsSafeAreaMinimum ?? this.controlsSafeAreaMinimum,
transformationController:
transformationController ?? this.transformationController,
materialSeekButtonFadeDuration:
materialSeekButtonFadeDuration ?? this.materialSeekButtonFadeDuration,
materialSeekButtonSize:
Expand Down Expand Up @@ -490,10 +496,14 @@ class ChewieController extends ChangeNotifier {
/// Whether or not to show the controls at all
final bool showControls;

/// Controller to pass into the [InteractiveViewer] component
/// Controller to pass into the [InteractiveViewer] component.
/// If it is required to control the transformation only via the controller,
/// `zoomAndPan` should be set to false.
final TransformationController? transformationController;

/// Whether or not to allow zooming and panning
/// Whether or not to allow zooming and panning.
/// This can still be false, and the `transformationController` can be used to control the
/// transformation.
final bool zoomAndPan;

/// Max scale when zooming
Expand Down
43 changes: 26 additions & 17 deletions lib/src/player_with_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,15 @@ class PlayerWithControls extends StatelessWidget {
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(
child: AspectRatio(
aspectRatio: chewieController.aspectRatio ??
chewieController.videoPlayerController.value.aspectRatio,
child: VideoPlayer(chewieController.videoPlayerController),
),
final playerNotifier = Provider.of<PlayerNotifier>(context, listen: false);
final child = Stack(
children: [
if (chewieController.placeholder != null) chewieController.placeholder!,
Center(
child: AspectRatio(
aspectRatio: chewieController.aspectRatio ??
chewieController.videoPlayerController.value.aspectRatio,
child: VideoPlayer(chewieController.videoPlayerController),
),
),
if (chewieController.overlay != null) chewieController.overlay!,
Expand Down Expand Up @@ -81,10 +75,25 @@ class PlayerWithControls extends StatelessWidget {
),
],
);

if (chewieController.zoomAndPan || chewieController.transformationController != null) {
return InteractiveViewer(
transformationController: chewieController.transformationController,
maxScale: chewieController.maxScale,
panEnabled: chewieController.zoomAndPan,
scaleEnabled: chewieController.zoomAndPan,
onInteractionUpdate:
chewieController.zoomAndPan ? (_) => playerNotifier.hideStuff = true : null,
onInteractionEnd:
chewieController.zoomAndPan ? (_) => playerNotifier.hideStuff = false : null,
child: child,
);
}

return child;
}

return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
return Center(
child: SizedBox(
height: constraints.maxHeight,
Expand Down
Loading