opt: subtitle & video screenshot (#2364)

This commit is contained in:
My-Responsitories
2026-06-09 02:06:55 +00:00
committed by GitHub
parent 46d9f8ab1c
commit fe15024384
6 changed files with 68 additions and 77 deletions

View File

@@ -1724,50 +1724,52 @@ class PlPlayerController with BlockConfigMixin {
videoShot = await VideoHttp.videoshot(bvid: bvid, cid: cid!);
}
void takeScreenshot() {
Future<void> takeScreenshot() async {
SmartDialog.showToast('截图中');
videoPlayerController?.screenshot(format: .png).then((value) {
if (value != null) {
SmartDialog.showToast('点击弹窗保存截图');
showDialog(
context: Get.context!,
builder: (context) => GestureDetector(
onTap: () {
Get.back();
final image = await videoPlayerController?.screenshot();
if (image != null) {
SmartDialog.showToast('点击弹窗保存截图');
showDialog(
context: Get.context!,
builder: (context) => GestureDetector(
onTap: () async {
final bytes = await image.toByteData(format: .png);
if (bytes != null) {
ImageUtils.saveByteImg(
bytes: value,
bytes: bytes.buffer.asUint8List(),
fileName: 'screenshot_${ImageUtils.time}',
);
},
child: Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.only(right: 12),
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: min(DeviceUtils.size.width / 3, 350),
}
Get.back();
},
child: Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.only(right: 12),
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: min(MediaQuery.widthOf(context) / 3, 350),
),
child: DecoratedBox(
decoration: BoxDecoration(
border: Border.all(
width: 5,
color: ThemeUtils.theme.colorScheme.surface,
),
),
child: DecoratedBox(
decoration: BoxDecoration(
border: Border.all(
width: 5,
color: ThemeUtils.theme.colorScheme.surface,
),
),
child: Padding(
padding: const EdgeInsets.all(5),
child: Image.memory(value),
),
child: Padding(
padding: const EdgeInsets.all(5),
child: RawImage(image: image),
),
),
),
),
),
);
} else {
SmartDialog.showToast('截图失败');
}
});
),
).whenComplete(image.dispose);
} else {
SmartDialog.showToast('截图失败');
}
}
void onPopInvokedWithResult(bool didPop, Object? result) {