mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: 解码格式分为首选和次选,调整部分设置文案
This commit is contained in:
@@ -24,6 +24,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
late dynamic defaultVideoQa;
|
late dynamic defaultVideoQa;
|
||||||
late dynamic defaultAudioQa;
|
late dynamic defaultAudioQa;
|
||||||
late dynamic defaultDecode;
|
late dynamic defaultDecode;
|
||||||
|
late dynamic secondDecode;
|
||||||
late String defaultSubtitlePreference;
|
late String defaultSubtitlePreference;
|
||||||
late int defaultFullScreenMode;
|
late int defaultFullScreenMode;
|
||||||
late int defaultBtmProgressBehavior;
|
late int defaultBtmProgressBehavior;
|
||||||
@@ -37,6 +38,8 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
defaultValue: AudioQuality.values.last.code);
|
defaultValue: AudioQuality.values.last.code);
|
||||||
defaultDecode = setting.get(SettingBoxKey.defaultDecode,
|
defaultDecode = setting.get(SettingBoxKey.defaultDecode,
|
||||||
defaultValue: VideoDecodeFormats.values.last.code);
|
defaultValue: VideoDecodeFormats.values.last.code);
|
||||||
|
secondDecode = setting.get(SettingBoxKey.secondDecode,
|
||||||
|
defaultValue: VideoDecodeFormats.values[1].code);
|
||||||
defaultFullScreenMode = setting.get(SettingBoxKey.fullScreenMode,
|
defaultFullScreenMode = setting.get(SettingBoxKey.fullScreenMode,
|
||||||
defaultValue: FullScreenMode.values.first.code);
|
defaultValue: FullScreenMode.values.first.code);
|
||||||
defaultBtmProgressBehavior = setting.get(SettingBoxKey.btmProgressBehavior,
|
defaultBtmProgressBehavior = setting.get(SettingBoxKey.btmProgressBehavior,
|
||||||
@@ -163,7 +166,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
dense: false,
|
dense: false,
|
||||||
title: Text('默认画质', style: titleStyle),
|
title: Text('默认画质', style: titleStyle),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
'当前画质${VideoQualityCode.fromCode(defaultVideoQa)!.description!}',
|
'当前画质:${VideoQualityCode.fromCode(defaultVideoQa)!.description!}',
|
||||||
style: subTitleStyle,
|
style: subTitleStyle,
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
@@ -189,7 +192,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
dense: false,
|
dense: false,
|
||||||
title: Text('默认音质', style: titleStyle),
|
title: Text('默认音质', style: titleStyle),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
'当前音质${AudioQualityCode.fromCode(defaultAudioQa)!.description!}',
|
'当前音质:${AudioQualityCode.fromCode(defaultAudioQa)!.description!}',
|
||||||
style: subTitleStyle,
|
style: subTitleStyle,
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
@@ -213,9 +216,9 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
dense: false,
|
dense: false,
|
||||||
title: Text('默认解码格式', style: titleStyle),
|
title: Text('首选解码格式', style: titleStyle),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
'当前解码格式${VideoDecodeFormatsCode.fromCode(defaultDecode)!.description!}',
|
'首选解码格式:${VideoDecodeFormatsCode.fromCode(defaultDecode)!.description!},请根据设备支持情况与需求调整',
|
||||||
style: subTitleStyle,
|
style: subTitleStyle,
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
@@ -237,9 +240,35 @@ class _PlaySettingState extends State<PlaySetting> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: false,
|
||||||
|
title: Text('次选解码格式', style: titleStyle),
|
||||||
|
subtitle: Text(
|
||||||
|
'非杜比视频次选:${VideoDecodeFormatsCode.fromCode(secondDecode)!.description!},仍无则选择首个提供的解码格式',
|
||||||
|
style: subTitleStyle,
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
String? result = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return SelectDialog<String>(
|
||||||
|
title: '次选解码格式',
|
||||||
|
value: secondDecode,
|
||||||
|
values: VideoDecodeFormats.values.map((e) {
|
||||||
|
return {'title': e.description, 'value': e.code};
|
||||||
|
}).toList());
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (result != null) {
|
||||||
|
secondDecode = result;
|
||||||
|
setting.put(SettingBoxKey.secondDecode, result);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
const SetSwitchItem(
|
const SetSwitchItem(
|
||||||
title: '开启硬解',
|
title: '开启硬解',
|
||||||
subTitle: '以较低功耗播放视频',
|
subTitle: '以较低功耗播放视频,若使用中异常卡死,请尝试关闭',
|
||||||
setKey: SettingBoxKey.enableHA,
|
setKey: SettingBoxKey.enableHA,
|
||||||
defaultVal: true,
|
defaultVal: true,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ class VideoDetailController extends GetxController
|
|||||||
late bool enableCDN;
|
late bool enableCDN;
|
||||||
late int? cacheVideoQa;
|
late int? cacheVideoQa;
|
||||||
late String cacheDecode;
|
late String cacheDecode;
|
||||||
|
late String cacheSecondDecode;
|
||||||
late int cacheAudioQa;
|
late int cacheAudioQa;
|
||||||
|
|
||||||
PersistentBottomSheetController? replyReplyBottomSheetCtr;
|
PersistentBottomSheetController? replyReplyBottomSheetCtr;
|
||||||
@@ -136,6 +137,8 @@ class VideoDetailController extends GetxController
|
|||||||
// 预设的解码格式
|
// 预设的解码格式
|
||||||
cacheDecode = setting.get(SettingBoxKey.defaultDecode,
|
cacheDecode = setting.get(SettingBoxKey.defaultDecode,
|
||||||
defaultValue: VideoDecodeFormats.values.last.code);
|
defaultValue: VideoDecodeFormats.values.last.code);
|
||||||
|
cacheSecondDecode = setting.get(SettingBoxKey.secondDecode,
|
||||||
|
defaultValue: VideoDecodeFormats.values[1].code);
|
||||||
cacheAudioQa = setting.get(SettingBoxKey.defaultAudioQa,
|
cacheAudioQa = setting.get(SettingBoxKey.defaultAudioQa,
|
||||||
defaultValue: AudioQuality.hiRes.code);
|
defaultValue: AudioQuality.hiRes.code);
|
||||||
oid.value = IdUtils.bv2av(Get.parameters['bvid']!);
|
oid.value = IdUtils.bv2av(Get.parameters['bvid']!);
|
||||||
@@ -172,23 +175,52 @@ class VideoDetailController extends GetxController
|
|||||||
/// 根据currentVideoQa和currentDecodeFormats 重新设置videoUrl
|
/// 根据currentVideoQa和currentDecodeFormats 重新设置videoUrl
|
||||||
List<VideoItem> videoList =
|
List<VideoItem> videoList =
|
||||||
data.dash!.video!.where((i) => i.id == currentVideoQa.code).toList();
|
data.dash!.video!.where((i) => i.id == currentVideoQa.code).toList();
|
||||||
|
|
||||||
|
final List supportDecodeFormats = videoList.map((e) => e.codecs!).toList();
|
||||||
|
VideoDecodeFormats defaultDecodeFormats =
|
||||||
|
VideoDecodeFormatsCode.fromString(cacheDecode)!;
|
||||||
|
VideoDecodeFormats secondDecodeFormats =
|
||||||
|
VideoDecodeFormatsCode.fromString(cacheSecondDecode)!;
|
||||||
try {
|
try {
|
||||||
firstVideo = videoList
|
// 当前视频没有对应格式返回第一个
|
||||||
.firstWhere((i) => i.codecs!.startsWith(currentDecodeFormats.code));
|
int flag = 0;
|
||||||
} catch (_) {
|
for (var i in supportDecodeFormats) {
|
||||||
if (currentVideoQa == VideoQuality.dolbyVision) {
|
if (i.startsWith(currentDecodeFormats.code)) {
|
||||||
|
flag = 1;
|
||||||
|
break;
|
||||||
|
} else if (i.startsWith(defaultDecodeFormats.code)) {
|
||||||
|
flag += 2;
|
||||||
|
} else if (i.startsWith(secondDecodeFormats.code)) {
|
||||||
|
flag += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flag == 1) {//currentDecodeFormats
|
||||||
firstVideo = videoList.first;
|
firstVideo = videoList.first;
|
||||||
|
} else {
|
||||||
|
if (currentVideoQa == VideoQuality.dolbyVision) {
|
||||||
currentDecodeFormats =
|
currentDecodeFormats =
|
||||||
VideoDecodeFormatsCode.fromString(videoList.first.codecs!)!;
|
VideoDecodeFormatsCode.fromString(videoList.first.codecs!)!;
|
||||||
} else {
|
firstVideo = videoList.first;
|
||||||
// 当前格式不可用
|
} else if (flag == 2 || flag == 6) {//defaultDecodeFormats
|
||||||
currentDecodeFormats = VideoDecodeFormatsCode.fromString(setting.get(
|
currentDecodeFormats = defaultDecodeFormats;
|
||||||
SettingBoxKey.defaultDecode,
|
firstVideo = videoList.firstWhere(
|
||||||
defaultValue: VideoDecodeFormats.values.last.code))!;
|
(i) => i.codecs!.startsWith(defaultDecodeFormats.code),
|
||||||
firstVideo = videoList
|
);
|
||||||
.firstWhere((i) => i.codecs!.startsWith(currentDecodeFormats.code));
|
} else if (flag == 4) {//secondDecodeFormats
|
||||||
|
currentDecodeFormats = secondDecodeFormats;
|
||||||
|
firstVideo = videoList.firstWhere(
|
||||||
|
(i) => i.codecs!.startsWith(secondDecodeFormats.code),
|
||||||
|
);
|
||||||
|
} else if (flag == 0) {
|
||||||
|
currentDecodeFormats =
|
||||||
|
VideoDecodeFormatsCode.fromString(supportDecodeFormats.first)!;
|
||||||
|
firstVideo = videoList.first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
SmartDialog.showToast('DecodeFormats error: $err');
|
||||||
|
}
|
||||||
|
|
||||||
videoUrl = firstVideo.baseUrl!;
|
videoUrl = firstVideo.baseUrl!;
|
||||||
|
|
||||||
/// 根据currentAudioQa 重新设置audioUrl
|
/// 根据currentAudioQa 重新设置audioUrl
|
||||||
@@ -292,23 +324,30 @@ class VideoDetailController extends GetxController
|
|||||||
// 根据画质选编码格式
|
// 根据画质选编码格式
|
||||||
final List supportDecodeFormats =
|
final List supportDecodeFormats =
|
||||||
supportFormats.firstWhere((e) => e.quality == resVideoQa).codecs!;
|
supportFormats.firstWhere((e) => e.quality == resVideoQa).codecs!;
|
||||||
// 默认从设置中取AVC
|
// 默认从设置中取AV1
|
||||||
currentDecodeFormats = VideoDecodeFormatsCode.fromString(cacheDecode)!;
|
currentDecodeFormats = VideoDecodeFormatsCode.fromString(cacheDecode)!;
|
||||||
|
VideoDecodeFormats secondDecodeFormats =
|
||||||
|
VideoDecodeFormatsCode.fromString(cacheSecondDecode)!;
|
||||||
try {
|
try {
|
||||||
// 当前视频没有对应格式返回第一个
|
// 当前视频没有对应格式返回第一个
|
||||||
bool flag = false;
|
int flag = 0;
|
||||||
for (var i in supportDecodeFormats) {
|
for (var i in supportDecodeFormats) {
|
||||||
if (i.startsWith(currentDecodeFormats.code)) {
|
if (i.startsWith(currentDecodeFormats.code)) {
|
||||||
flag = true;
|
flag = 1;
|
||||||
|
break;
|
||||||
|
} else if (i.startsWith(secondDecodeFormats.code)) {
|
||||||
|
flag += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentDecodeFormats = flag
|
if (flag == 2) {
|
||||||
? currentDecodeFormats
|
currentDecodeFormats = secondDecodeFormats;
|
||||||
: VideoDecodeFormatsCode.fromString(supportDecodeFormats.first)!;
|
} else if (flag == 0) {
|
||||||
|
currentDecodeFormats =
|
||||||
|
VideoDecodeFormatsCode.fromString(supportDecodeFormats.first)!;
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
SmartDialog.showToast('DecodeFormats error: $err');
|
SmartDialog.showToast('DecodeFormats error: $err');
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 取出符合当前解码格式的videoItem
|
/// 取出符合当前解码格式的videoItem
|
||||||
try {
|
try {
|
||||||
firstVideo = videosList.firstWhere(
|
firstVideo = videosList.firstWhere(
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ class SettingBoxKey {
|
|||||||
autoPlayEnable = 'autoPlayEnable',
|
autoPlayEnable = 'autoPlayEnable',
|
||||||
fullScreenMode = 'fullScreenMode',
|
fullScreenMode = 'fullScreenMode',
|
||||||
defaultDecode = 'defaultDecode',
|
defaultDecode = 'defaultDecode',
|
||||||
|
secondDecode = 'secondDecode',
|
||||||
danmakuEnable = 'danmakuEnable',
|
danmakuEnable = 'danmakuEnable',
|
||||||
defaultToastOp = 'defaultToastOp',
|
defaultToastOp = 'defaultToastOp',
|
||||||
defaultPicQa = 'defaultPicQa',
|
defaultPicQa = 'defaultPicQa',
|
||||||
|
|||||||
Reference in New Issue
Block a user