mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: 新增更多CDN选项,且默认单独关闭音频CDN
This commit is contained in:
@@ -3,8 +3,10 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:PiliPalaX/models/video/play/quality.dart';
|
||||
import 'package:PiliPalaX/models/video/play/CDN.dart';
|
||||
import 'package:PiliPalaX/pages/setting/widgets/select_dialog.dart';
|
||||
import 'package:PiliPalaX/utils/storage.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
|
||||
import 'widgets/switch_item.dart';
|
||||
|
||||
@@ -23,6 +25,7 @@ class _VideoSettingState extends State<VideoSetting> {
|
||||
late dynamic secondDecode;
|
||||
late dynamic hardwareDecoding;
|
||||
late dynamic videoSync;
|
||||
late dynamic defaultCDNService;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -39,6 +42,8 @@ class _VideoSettingState extends State<VideoSetting> {
|
||||
defaultValue: Platform.isAndroid ? 'auto-safe' : 'auto');
|
||||
videoSync =
|
||||
setting.get(SettingBoxKey.videoSync, defaultValue: 'display-resample');
|
||||
defaultCDNService = setting.get(SettingBoxKey.CDNService,
|
||||
defaultValue: CDNService.ali.code);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -80,11 +85,37 @@ class _VideoSettingState extends State<VideoSetting> {
|
||||
setKey: SettingBoxKey.p1080,
|
||||
defaultVal: true,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: 'CDN优化',
|
||||
subTitle: '使用优质CDN线路',
|
||||
leading: Icon(Icons.network_check_outlined),
|
||||
setKey: SettingBoxKey.enableCDN,
|
||||
ListTile(
|
||||
title: Text('CDN 设置', style: titleStyle),
|
||||
leading: Icon(MdiIcons.cloudPlusOutline),
|
||||
subtitle: Text(
|
||||
'当前使用:${CDNServiceCode.fromCode(defaultCDNService)!.description},部分 CDN 可能失效,如无法播放请尝试切换',
|
||||
style: subTitleStyle,
|
||||
),
|
||||
onTap: () async {
|
||||
String? result = await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SelectDialog<String>(
|
||||
title: 'CDN 设置',
|
||||
value: defaultCDNService,
|
||||
values: CDNService.values.map((e) {
|
||||
return {'title': e.description, 'value': e.code};
|
||||
}).toList());
|
||||
},
|
||||
);
|
||||
if (result != null) {
|
||||
defaultCDNService = result;
|
||||
setting.put(SettingBoxKey.CDNService, result);
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
SetSwitchItem(
|
||||
title: '音频不跟随 CDN 设置',
|
||||
subTitle: '直接采用备用 URL,可解决部分视频无声',
|
||||
leading: Icon(MdiIcons.musicNotePlus),
|
||||
setKey: SettingBoxKey.disableAudioCDN,
|
||||
defaultVal: true,
|
||||
),
|
||||
ListTile(
|
||||
@@ -117,7 +148,7 @@ class _VideoSettingState extends State<VideoSetting> {
|
||||
ListTile(
|
||||
dense: false,
|
||||
title: Text('默认音质', style: titleStyle),
|
||||
leading: const Icon(Icons.audiotrack_outlined),
|
||||
leading: const Icon(Icons.music_video_outlined),
|
||||
subtitle: Text(
|
||||
'当前音质:${AudioQualityCode.fromCode(defaultAudioQa)!.description!}',
|
||||
style: subTitleStyle,
|
||||
|
||||
Reference in New Issue
Block a user