Skip to content

Commit

Permalink
mod: add restore video scale button
Browse files Browse the repository at this point in the history
related #222

Signed-off-by: bggRGjQaUbCoE <[email protected]>
  • Loading branch information
bggRGjQaUbCoE committed Feb 10, 2025
1 parent 52175b0 commit 7c50754
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/plugin/pl_player/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1611,4 +1611,6 @@ class PlPlayerController {

late final RxList dmTrend = [].obs;
late final RxBool showDmChart = true.obs;

late final RxDouble videoScale = 1.0.obs;
}
69 changes: 69 additions & 0 deletions lib/plugin/pl_player/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
_listener?.cancel();
animationController.dispose();
FlutterVolumeController.removeListener();
transformationController.dispose();
super.dispose();
}

Expand Down Expand Up @@ -669,6 +670,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>

bool get isFullScreen => plPlayerController.isFullScreen.value;

late final transformationController = TransformationController();

@override
Widget build(BuildContext context) {
final Color colorTheme = Theme.of(context).colorScheme.primary;
Expand All @@ -682,6 +685,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
children: <Widget>[
Obx(
() => InteractiveViewer(
transformationController: transformationController,
panEnabled: false, // 启用平移 //单指平移会与横竖手势冲突
scaleEnabled: !plPlayerController.controlsLock.value, // 启用缩放
minScale: 1.0,
Expand Down Expand Up @@ -813,6 +817,8 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
}
},
onInteractionEnd: (ScaleEndDetails details) {
plPlayerController.videoScale.value =
transformationController.value.row0.x;
if (plPlayerController.showSeekPreview) {
plPlayerController.showPreview.value = false;
}
Expand Down Expand Up @@ -1126,6 +1132,69 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
),
),

// if (BuildConfig.isDebug)
// FilledButton.tonal(
// onPressed: () {
// transformationController.value = Matrix4.identity()
// ..translate(0.5, 0.5)
// ..scale(1.2)
// ..translate(-0.5, -0.5);

// plPlayerController.videoScale.value =
// transformationController.value.row0.x;
// },
// child: const Text('scale'),
// ),

Obx(
() => plPlayerController.videoScale.value != 1 &&
plPlayerController.showControls.value
? Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.only(bottom: 75),
child: FilledButton.tonal(
style: FilledButton.styleFrom(
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
backgroundColor: Theme.of(context)
.colorScheme
.secondaryContainer
.withOpacity(0.8),
visualDensity:
VisualDensity(horizontal: -2, vertical: -2),
padding: const EdgeInsets.symmetric(
horizontal: 15, vertical: 15),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
),
),
onPressed: () async {
plPlayerController.videoScale.value = 1.0;
final animController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 255),
);
final anim = Matrix4Tween(
begin: transformationController.value,
end: Matrix4.identity(),
).animate(
CurveTween(curve: Curves.easeOut)
.animate(animController),
);
animController.addListener(() {
transformationController.value = anim.value;
});
await animController.forward(from: 0);
animController.removeListener(() {});
animController.dispose();
},
child: Text('还原屏幕'),
),
),
)
: const SizedBox.shrink(),
),

/// 进度条 live模式下禁用
Obx(
() {
Expand Down

0 comments on commit 7c50754

Please sign in to comment.