mod: 画面比例 issues #229

This commit is contained in:
guozhigq
2023-11-04 21:07:27 +08:00
parent 3613e27643
commit eaff4def1c
2 changed files with 43 additions and 31 deletions

View File

@ -200,7 +200,7 @@ class _HeaderControlState extends State<HeaderControl> {
onPressed: () async { onPressed: () async {
// setState(() => currentSpeed = i), // setState(() => currentSpeed = i),
await widget.controller!.setPlaybackSpeed(i); await widget.controller!.setPlaybackSpeed(i);
SmartDialog.dismiss(); Get.back();
}, },
child: Text(i.toString()), child: Text(i.toString()),
), ),
@ -209,7 +209,7 @@ class _HeaderControlState extends State<HeaderControl> {
onPressed: () async { onPressed: () async {
// setState(() => currentSpeed = i), // setState(() => currentSpeed = i),
await widget.controller!.setPlaybackSpeed(i); await widget.controller!.setPlaybackSpeed(i);
SmartDialog.dismiss(); Get.back();
}, },
child: Text(i.toString()), child: Text(i.toString()),
), ),
@ -229,7 +229,7 @@ class _HeaderControlState extends State<HeaderControl> {
TextButton( TextButton(
onPressed: () async { onPressed: () async {
await widget.controller!.setDefaultSpeed(); await widget.controller!.setDefaultSpeed();
SmartDialog.dismiss(); Get.back();
}, },
child: const Text('默认速度'), child: const Text('默认速度'),
), ),

View File

@ -270,14 +270,6 @@ class PlPlayerController {
// 获取实例 传参 // 获取实例 传参
static PlPlayerController getInstance({ static PlPlayerController getInstance({
String videoType = 'archive', String videoType = 'archive',
List<BoxFit> fits = const [
BoxFit.contain,
BoxFit.cover,
BoxFit.fill,
BoxFit.fitHeight,
BoxFit.fitWidth,
BoxFit.scaleDown
],
}) { }) {
// 如果实例尚未创建,则创建一个新实例 // 如果实例尚未创建,则创建一个新实例
_instance ??= PlPlayerController._(); _instance ??= PlPlayerController._();
@ -766,26 +758,46 @@ class PlPlayerController {
/// Toggle Change the videofit accordingly /// Toggle Change the videofit accordingly
void toggleVideoFit() { void toggleVideoFit() {
videoFitChangedTimer?.cancel(); showDialog(
videoFitChanged.value = true; context: Get.context!,
// 范围内 builder: (context) {
List attrs = videoFitType.map((e) => e['attr']).toList(); return AlertDialog(
if (attrs.indexOf(_videoFit.value) < attrs.length - 1) { title: const Text('画面比例'),
int index = attrs.indexOf(_videoFit.value); content: StatefulBuilder(builder: (context, StateSetter setState) {
_videoFit.value = attrs[index + 1]; return Wrap(
_videoFitDesc.value = videoFitType[index + 1]['desc']; alignment: WrapAlignment.start,
SmartDialog.showToast(videoFitType[index + 1]['desc']); spacing: 8,
} else { runSpacing: 2,
// 默认 contain children: [
_videoFit.value = videoFitType.first['attr']; for (var i in videoFitType) ...[
_videoFitDesc.value = videoFitType.first['desc']; if (_videoFit.value == i['attr']) ...[
SmartDialog.showToast(videoFitType.first['desc']); FilledButton(
} onPressed: () async {
videoFitChangedTimer = Timer(const Duration(seconds: 1), () { _videoFit.value = i['attr'];
videoFitChangedTimer = null; _videoFitDesc.value = i['desc'];
videoFitChanged.value = false; setVideoFit();
}); Get.back();
setVideoFit(); },
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 /// 缓存fit