fix: supportFormats codecs match dvh1
This commit is contained in:
@ -93,26 +93,19 @@ extension AudioQualityDesc on AudioQuality {
|
||||
}
|
||||
|
||||
enum VideoDecodeFormats {
|
||||
DVH1,
|
||||
AV1,
|
||||
HEVC,
|
||||
AVC,
|
||||
}
|
||||
|
||||
extension VideoDecodeFormatsDesc on VideoDecodeFormats {
|
||||
static final List<String> _descList = [
|
||||
'AV1',
|
||||
'HEVC',
|
||||
'AVC',
|
||||
];
|
||||
static final List<String> _descList = ['DVH1', 'AV1', 'HEVC', 'AVC'];
|
||||
get description => _descList[index];
|
||||
}
|
||||
|
||||
extension VideoDecodeFormatsCode on VideoDecodeFormats {
|
||||
static final List<String> _codeList = [
|
||||
'av01',
|
||||
'hev1',
|
||||
'avc1',
|
||||
];
|
||||
static final List<String> _codeList = ['dvh1', 'av01', 'hev1', 'avc1'];
|
||||
get code => _codeList[index];
|
||||
|
||||
static VideoDecodeFormats? fromCode(String code) {
|
||||
|
@ -140,8 +140,17 @@ class VideoDetailController extends GetxController
|
||||
/// 根据currentVideoQa和currentDecodeFormats 重新设置videoUrl
|
||||
List<VideoItem> videoList =
|
||||
data.dash!.video!.where((i) => i.id == currentVideoQa.code).toList();
|
||||
firstVideo = videoList
|
||||
.firstWhere((i) => i.codecs!.startsWith(currentDecodeFormats.code));
|
||||
try {
|
||||
firstVideo = videoList
|
||||
.firstWhere((i) => i.codecs!.startsWith(currentDecodeFormats.code));
|
||||
} catch (_) {
|
||||
// 当前格式不可用
|
||||
currentDecodeFormats = VideoDecodeFormatsCode.fromString(setting.get(
|
||||
SettingBoxKey.defaultDecode,
|
||||
defaultValue: VideoDecodeFormats.values.last.code))!;
|
||||
firstVideo = videoList
|
||||
.firstWhere((i) => i.codecs!.startsWith(currentDecodeFormats.code));
|
||||
}
|
||||
videoUrl = firstVideo.baseUrl!;
|
||||
|
||||
/// 根据currentAudioQa 重新设置audioUrl
|
||||
@ -243,17 +252,25 @@ class VideoDetailController extends GetxController
|
||||
defaultValue: VideoDecodeFormats.values.last.code))!;
|
||||
try {
|
||||
// 当前视频没有对应格式返回第一个
|
||||
currentDecodeFormats =
|
||||
supportDecodeFormats.contains(supportDecodeFormats)
|
||||
? supportDecodeFormats
|
||||
: supportDecodeFormats.first;
|
||||
} catch (_) {}
|
||||
currentDecodeFormats = supportDecodeFormats
|
||||
.contains(currentDecodeFormats)
|
||||
? currentDecodeFormats
|
||||
: VideoDecodeFormatsCode.fromString(supportDecodeFormats.first)!;
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
|
||||
/// 取出符合当前解码格式的videoItem
|
||||
firstVideo = videosList
|
||||
.firstWhere((e) => e.codecs!.startsWith(currentDecodeFormats.code));
|
||||
try {
|
||||
firstVideo = videosList.firstWhere(
|
||||
(e) => e.codecs!.startsWith(currentDecodeFormats.code));
|
||||
} catch (_) {
|
||||
firstVideo = videosList.first;
|
||||
}
|
||||
videoUrl = firstVideo.baseUrl!;
|
||||
} catch (_) {}
|
||||
} catch (err) {
|
||||
print(err);
|
||||
}
|
||||
|
||||
/// 优先顺序 设置中指定质量 -> 当前可选的最高质量
|
||||
late AudioItem firstAudio;
|
||||
|
@ -387,9 +387,12 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
// 当前选中的解码格式
|
||||
VideoDecodeFormats currentDecodeFormats =
|
||||
widget.videoDetailCtr!.currentDecodeFormats;
|
||||
VideoItem firstVideo = widget.videoDetailCtr!.firstVideo;
|
||||
// 当前视频可用的解码格式
|
||||
List<FormatItem> videoFormat = videoInfo.supportFormats!;
|
||||
List list = videoFormat.first.codecs!;
|
||||
List list = videoFormat
|
||||
.firstWhere((e) => e.quality == firstVideo.quality!.code)
|
||||
.codecs!;
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
|
Reference in New Issue
Block a user