mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 00:28:18 +08:00
@@ -16,6 +16,8 @@ import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:PiliPlus/utils/video_utils.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart' show FilteringTextInputFormatter;
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
|
||||
@@ -149,7 +151,12 @@ List<SettingsModel> get videoSettings => [
|
||||
setKey: SettingBoxKey.expandBuffer,
|
||||
defaultVal: false,
|
||||
),
|
||||
//video-sync
|
||||
NormalModel(
|
||||
title: '自动同步',
|
||||
leading: const Icon(Icons.sync_rounded),
|
||||
getSubtitle: () => '当前:${Pref.autosync}(此项即mpv的--autosync)',
|
||||
onTap: _showAutoSyncDialog,
|
||||
),
|
||||
NormalModel(
|
||||
title: '视频同步',
|
||||
leading: const Icon(Icons.view_timeline_outlined),
|
||||
@@ -447,3 +454,43 @@ Future<void> _showHwDecDialog(
|
||||
setState();
|
||||
}
|
||||
}
|
||||
|
||||
void _showAutoSyncDialog(BuildContext context, VoidCallback setState) {
|
||||
String autosync = Pref.autosync.toString();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('自动同步'),
|
||||
content: TextFormField(
|
||||
autofocus: true,
|
||||
initialValue: autosync,
|
||||
keyboardType: TextInputType.number,
|
||||
onChanged: (value) => autosync = value,
|
||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(color: ColorScheme.of(context).outline),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
try {
|
||||
// validate
|
||||
int.parse(autosync);
|
||||
Get.back();
|
||||
await GStorage.setting.put(SettingBoxKey.autosync, autosync);
|
||||
setState();
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
},
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -800,7 +800,7 @@ class PlPlayerController {
|
||||
}
|
||||
// video-sync=display-resample
|
||||
await pp.setProperty("video-sync", Pref.videoSync);
|
||||
await pp.setProperty("autosync", "30");
|
||||
await pp.setProperty("autosync", Pref.autosync);
|
||||
// vo=gpu-next & gpu-context=android & gpu-api=opengl
|
||||
// await pp.setProperty("vo", "gpu-next");
|
||||
// await pp.setProperty("gpu-context", "android");
|
||||
|
||||
@@ -17,6 +17,7 @@ abstract final class SettingBoxKey {
|
||||
expandBuffer = 'expandBuffer',
|
||||
hardwareDecoding = 'hardwareDecoding',
|
||||
videoSync = 'videoSync',
|
||||
autosync = 'autosync',
|
||||
p1080 = 'p1080',
|
||||
enableAutoEnter = 'enableAutoEnter',
|
||||
enableAutoExit = 'enableAutoExit',
|
||||
|
||||
@@ -252,6 +252,9 @@ abstract final class Pref {
|
||||
static String get videoSync =>
|
||||
_setting.get(SettingBoxKey.videoSync, defaultValue: 'display-resample');
|
||||
|
||||
static String get autosync =>
|
||||
_setting.get(SettingBoxKey.autosync, defaultValue: '30');
|
||||
|
||||
static CDNService get defaultCDNService {
|
||||
if (_setting.get(SettingBoxKey.CDNService) case final String cdnName) {
|
||||
return CDNService.values.byName(cdnName);
|
||||
|
||||
Reference in New Issue
Block a user