From eaff4def1c98493b5632014127c6be1299f7c6f4 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 4 Nov 2023 21:07:27 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E7=94=BB=E9=9D=A2=E6=AF=94=E4=BE=8B=20i?= =?UTF-8?q?ssues=20#229?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../video/detail/widgets/header_control.dart | 6 +- lib/plugin/pl_player/controller.dart | 68 +++++++++++-------- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index 97502177..1d91bf50 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -200,7 +200,7 @@ class _HeaderControlState extends State { onPressed: () async { // setState(() => currentSpeed = i), await widget.controller!.setPlaybackSpeed(i); - SmartDialog.dismiss(); + Get.back(); }, child: Text(i.toString()), ), @@ -209,7 +209,7 @@ class _HeaderControlState extends State { onPressed: () async { // setState(() => currentSpeed = i), await widget.controller!.setPlaybackSpeed(i); - SmartDialog.dismiss(); + Get.back(); }, child: Text(i.toString()), ), @@ -229,7 +229,7 @@ class _HeaderControlState extends State { TextButton( onPressed: () async { await widget.controller!.setDefaultSpeed(); - SmartDialog.dismiss(); + Get.back(); }, child: const Text('默认速度'), ), diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 73229b72..4d4d1a9b 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -270,14 +270,6 @@ class PlPlayerController { // 获取实例 传参 static PlPlayerController getInstance({ String videoType = 'archive', - List fits = const [ - BoxFit.contain, - BoxFit.cover, - BoxFit.fill, - BoxFit.fitHeight, - BoxFit.fitWidth, - BoxFit.scaleDown - ], }) { // 如果实例尚未创建,则创建一个新实例 _instance ??= PlPlayerController._(); @@ -766,26 +758,46 @@ class PlPlayerController { /// Toggle Change the videofit accordingly void toggleVideoFit() { - videoFitChangedTimer?.cancel(); - videoFitChanged.value = true; - // 范围内 - List attrs = videoFitType.map((e) => e['attr']).toList(); - if (attrs.indexOf(_videoFit.value) < attrs.length - 1) { - int index = attrs.indexOf(_videoFit.value); - _videoFit.value = attrs[index + 1]; - _videoFitDesc.value = videoFitType[index + 1]['desc']; - SmartDialog.showToast(videoFitType[index + 1]['desc']); - } else { - // 默认 contain - _videoFit.value = videoFitType.first['attr']; - _videoFitDesc.value = videoFitType.first['desc']; - SmartDialog.showToast(videoFitType.first['desc']); - } - videoFitChangedTimer = Timer(const Duration(seconds: 1), () { - videoFitChangedTimer = null; - videoFitChanged.value = false; - }); - setVideoFit(); + showDialog( + context: Get.context!, + builder: (context) { + return AlertDialog( + title: const Text('画面比例'), + content: StatefulBuilder(builder: (context, StateSetter setState) { + return Wrap( + alignment: WrapAlignment.start, + spacing: 8, + runSpacing: 2, + children: [ + for (var i in videoFitType) ...[ + if (_videoFit.value == i['attr']) ...[ + FilledButton( + onPressed: () async { + _videoFit.value = i['attr']; + _videoFitDesc.value = i['desc']; + setVideoFit(); + Get.back(); + }, + child: Text(i['desc']), + ), + ] else ...[ + FilledButton.tonal( + onPressed: () async { + _videoFit.value = i['attr']; + _videoFitDesc.value = i['desc']; + setVideoFit(); + Get.back(); + }, + child: Text(i['desc']), + ), + ] + ] + ], + ); + }), + ); + }, + ); } /// 缓存fit