fix dolby videos playing (#1202)

This commit is contained in:
Kofua
2025-09-07 11:35:12 +08:00
committed by GitHub
parent e02835ddc4
commit d285f00086
5 changed files with 36 additions and 23 deletions

View File

@@ -1,19 +1,19 @@
// ignore_for_file: constant_identifier_names
enum VideoDecodeFormatType {
DVH1('dvh1'),
AV1('av01'),
HEVC('hev1'),
AVC('avc1');
DVH1(['dvh1']),
AV1(['av01']),
HEVC(['hev1', 'hvc1']),
AVC(['avc1']);
String get description => name;
final String code;
final List<String> codes;
const VideoDecodeFormatType(this.code);
const VideoDecodeFormatType(this.codes);
static VideoDecodeFormatType fromCode(String code) =>
values.firstWhere((i) => i.code == code);
values.firstWhere((i) => i.codes.contains(code));
static VideoDecodeFormatType fromString(String val) =>
values.firstWhere((i) => val.startsWith(i.code));
values.firstWhere((i) => i.codes.any(val.startsWith));
}

View File

@@ -251,7 +251,7 @@ List<SettingsModel> get videoSettings => [
title: '默认解码格式',
value: Pref.defaultDecode,
values: VideoDecodeFormatType.values
.map((e) => (e.code, e.description))
.map((e) => (e.codes.first, e.description))
.toList(),
);
},
@@ -276,7 +276,7 @@ List<SettingsModel> get videoSettings => [
title: '次选解码格式',
value: Pref.secondDecode,
values: VideoDecodeFormatType.values
.map((e) => (e.code, e.description))
.map((e) => (e.codes.first, e.description))
.toList(),
);
},

View File

@@ -99,6 +99,7 @@ class VideoDetailController extends GetxController
late Rx<VideoQuality> currentVideoQa;
AudioQuality? currentAudioQa;
late VideoDecodeFormatType currentDecodeFormats;
// 是否开始自动播放 存在多p的情况下第二p需要为true
final RxBool autoPlay = true.obs;
@@ -114,6 +115,7 @@ class VideoDetailController extends GetxController
String? audioUrl;
Duration? defaultST;
Duration? playedTime;
// 亮度
double? brightness;
@@ -142,6 +144,7 @@ class VideoDetailController extends GetxController
late bool isExpanding = false;
late bool isCollapsing = false;
AnimationController? _animationController;
AnimationController get animationController =>
_animationController ??= AnimationController(
vsync: this,
@@ -421,7 +424,9 @@ class VideoDetailController extends GetxController
}
bool isPortrait = true;
bool get horizontalScreen => plPlayerController.horizontalScreen;
bool get showVideoSheet => !horizontalScreen && !isPortrait;
int? _lastPos;
@@ -429,9 +434,11 @@ class VideoDetailController extends GetxController
RxList<SegmentModel> segmentList = <SegmentModel>[].obs;
List<Segment> viewPointList = <Segment>[];
List<Segment>? segmentProgressList;
Color _getColor(SegmentType segment) =>
plPlayerController.blockColor[segment.index];
late RxString videoLabel = ''.obs;
String get blockServer => plPlayerController.blockServer;
Timer? skipTimer;
@@ -993,23 +1000,23 @@ class VideoDetailController extends GetxController
/// 根据currentVideoQa和currentDecodeFormats 重新设置videoUrl
final videoList = data.dash!.video!.where((i) => i.id == qa).toList();
final currentDecodeFormats = this.currentDecodeFormats.code;
final currentDecodeFormats = this.currentDecodeFormats.codes;
final defaultDecodeFormats = VideoDecodeFormatType.fromString(
cacheDecode,
).code;
).codes;
final secondDecodeFormats = VideoDecodeFormatType.fromString(
cacheSecondDecode,
).code;
).codes;
VideoItem? video;
for (var i in videoList) {
final codec = i.codecs!;
if (codec.startsWith(currentDecodeFormats)) {
if (currentDecodeFormats.any(codec.startsWith)) {
video = i;
break;
} else if (codec.startsWith(defaultDecodeFormats)) {
} else if (defaultDecodeFormats.any(codec.startsWith)) {
video = i;
} else if (video == null && codec.startsWith(secondDecodeFormats)) {
} else if (video == null && secondDecodeFormats.any(codec.startsWith)) {
video = i;
}
}
@@ -1108,6 +1115,7 @@ class VideoDetailController extends GetxController
}
bool isQuerying = false;
// 视频链接
Future<void> queryVideoUrl({
Duration? defaultST,
@@ -1226,10 +1234,10 @@ class VideoDetailController extends GetxController
// 当前视频没有对应格式返回第一个
int flag = 0;
for (var i in supportDecodeFormats) {
if (i.startsWith(currentDecodeFormats.code)) {
if (currentDecodeFormats.codes.any(i.startsWith)) {
flag = 1;
break;
} else if (i.startsWith(secondDecodeFormats.code)) {
} else if (secondDecodeFormats.codes.any(i.startsWith)) {
flag = 2;
}
}
@@ -1243,7 +1251,7 @@ class VideoDetailController extends GetxController
/// 取出符合当前解码格式的videoItem
firstVideo = videosList.firstWhere(
(e) => e.codecs!.startsWith(currentDecodeFormats.code),
(e) => currentDecodeFormats.codes.any(e.codecs!.startsWith),
orElse: () => videosList.first,
);
setVideoHeight();
@@ -1405,6 +1413,7 @@ class VideoDetailController extends GetxController
int? graphVersion;
EdgeInfoData? steinEdgeInfo;
late final RxBool showSteinEdgeInfo = false.obs;
Future<void> getSteinEdgeInfo([int? edgeId]) async {
steinEdgeInfo = null;
try {

View File

@@ -55,6 +55,7 @@ class HeaderControl extends StatefulWidget {
required this.heroTag,
super.key,
});
final bool isPortrait;
final PlPlayerController controller;
final VideoDetailController videoDetailCtr;
@@ -70,6 +71,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
late final PlayUrlModel videoInfo = videoDetailCtr.data;
static const TextStyle subTitleStyle = TextStyle(fontSize: 12);
static const TextStyle titleStyle = TextStyle(fontSize: 14);
String get heroTag => widget.heroTag;
late final UgcIntroController ugcIntroController;
late final PgcIntroController pgcIntroController;
@@ -77,10 +79,12 @@ class HeaderControlState extends TripleState<HeaderControl> {
late CommonIntroController introController = videoDetailCtr.isUgc
? ugcIntroController
: pgcIntroController;
bool get isPortrait => widget.isPortrait;
late final horizontalScreen = videoDetailCtr.horizontalScreen;
RxString now = ''.obs;
Timer? clock;
bool get isFullScreen => plPlayerController.isFullScreen.value;
Box setting = GStorage.setting;
late final provider = ContextSingleTicker(context);
@@ -828,7 +832,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
ListTile(
dense: true,
onTap: () {
if (i.startsWith(currentDecodeFormats.code)) {
if (currentDecodeFormats.codes.any(i.startsWith)) {
return;
}
videoDetailCtr
@@ -848,7 +852,7 @@ class HeaderControlState extends TripleState<HeaderControl> {
i,
style: subTitleStyle,
),
trailing: i.startsWith(currentDecodeFormats.code)
trailing: currentDecodeFormats.codes.any(i.startsWith)
? Icon(
Icons.done,
color: theme.colorScheme.primary,

View File

@@ -218,12 +218,12 @@ abstract class Pref {
static String get defaultDecode => _setting.get(
SettingBoxKey.defaultDecode,
defaultValue: VideoDecodeFormatType.values.last.code,
defaultValue: VideoDecodeFormatType.values.last.codes.first,
);
static String get secondDecode => _setting.get(
SettingBoxKey.secondDecode,
defaultValue: VideoDecodeFormatType.AV1.code,
defaultValue: VideoDecodeFormatType.AV1.codes.first,
);
static String get hardwareDecoding => _setting.get(