From c7b67c3a10058f132da37d9df5f1655e4d8be4f3 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sat, 15 Jul 2023 16:26:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/video/play/url.dart | 4 +++- lib/pages/video/detail/controller.dart | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/models/video/play/url.dart b/lib/models/video/play/url.dart index 79b62036..a879fefb 100644 --- a/lib/models/video/play/url.dart +++ b/lib/models/video/play/url.dart @@ -78,7 +78,9 @@ class Dash { duration = json['duration']; minBufferTime = json['minBufferTime']; video = json['video'].map((e) => VideoItem.fromJson(e)).toList(); - audio = json['audio'].map((e) => AudioItem.fromJson(e)).toList(); + audio = json['audio'] != null + ? json['audio'].map((e) => AudioItem.fromJson(e)).toList() + : []; dolby = json['dolby']; flac = json['flac'] ?? ''; } diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index f90ddc56..06ae6886 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -125,7 +125,8 @@ class VideoDetailController extends GetxController PlayUrlModel data = result['data']; // 指定质量的视频 -> 最高质量的视频 String videoUrl = data.dash!.video!.first.baseUrl!; - String audioUrl = data.dash!.audio!.first.baseUrl!; + String audioUrl = + data.dash!.audio!.isNotEmpty ? data.dash!.audio!.first.baseUrl! : ''; playerInit(videoUrl, audioUrl, defaultST: Duration(milliseconds: data.lastPlayTime!)); }