fix: 没有audio 资源的视频异常

This commit is contained in:
guozhigq
2023-08-20 15:47:59 +08:00
parent 83341cd62b
commit 50a5653516
2 changed files with 17 additions and 14 deletions

View File

@ -38,7 +38,7 @@ class VideoDetailController extends GetxController
/// 播放器配置 画质 音质 解码格式
late VideoQuality currentVideoQa;
late AudioQuality currentAudioQa;
AudioQuality? currentAudioQa;
late VideoDecodeFormats currentDecodeFormats;
// PlPlayerController plPlayerController = PlPlayerController();
// 是否开始自动播放 存在多p的情况下第二p需要为true
@ -142,9 +142,11 @@ class VideoDetailController extends GetxController
videoUrl = firstVideo.baseUrl!;
/// 根据currentAudioQa 重新设置audioUrl
AudioItem firstAudio =
data.dash!.audio!.firstWhere((i) => i.id == currentAudioQa.code);
audioUrl = firstAudio.baseUrl ?? '';
if (currentAudioQa != null) {
AudioItem firstAudio =
data.dash!.audio!.firstWhere((i) => i.id == currentAudioQa!.code);
audioUrl = firstAudio.baseUrl ?? '';
}
playerInit();
}

View File

@ -120,15 +120,16 @@ class _HeaderControlState extends State<HeaderControl> {
'当前画质 ${widget.videoDetailCtr!.currentVideoQa.description}',
style: subTitleStyle),
),
ListTile(
onTap: () => {Get.back(), showSetAudioQa()},
dense: true,
leading: const Icon(Icons.album_outlined, size: 20),
title: Text('选择音质', style: titleStyle),
subtitle: Text(
'当前音质 ${widget.videoDetailCtr!.currentAudioQa.description}',
style: subTitleStyle),
),
if (widget.videoDetailCtr!.currentAudioQa != null)
ListTile(
onTap: () => {Get.back(), showSetAudioQa()},
dense: true,
leading: const Icon(Icons.album_outlined, size: 20),
title: Text('选择音质', style: titleStyle),
subtitle: Text(
'当前音质 ${widget.videoDetailCtr!.currentAudioQa!.description}',
style: subTitleStyle),
),
ListTile(
onTap: () => {Get.back(), showSetDecodeFormats()},
dense: true,
@ -319,7 +320,7 @@ class _HeaderControlState extends State<HeaderControl> {
/// 选择音质
void showSetAudioQa() {
AudioQuality currentAudioQa = widget.videoDetailCtr!.currentAudioQa;
AudioQuality currentAudioQa = widget.videoDetailCtr!.currentAudioQa!;
List<AudioItem> audio = videoInfo.dash!.audio!;
showModalBottomSheet(