diff --git a/lib/models/video/play/url.dart b/lib/models/video/play/url.dart index 4d9ff84f..bd3e3f3e 100644 --- a/lib/models/video/play/url.dart +++ b/lib/models/video/play/url.dart @@ -34,6 +34,7 @@ class PlayUrlModel { String? seekParam; String? seekType; Dash? dash; + List? durl; List? supportFormats; // String? highFormat; int? lastPlayTime; @@ -52,15 +53,8 @@ class PlayUrlModel { videoCodecid = json['video_codecid']; seekParam = json['seek_param']; seekType = json['seek_type']; - if (json['dash'] != null) { - dash = Dash.fromJson(json['dash']); - } else if (json['durl'] != null) { - //试看的充电包月视频可能出现没有dash只有durl的情况 - var durlList = json['durl'] - .map((e) => Durl.fromJson(e)) - .toList(); - //TODO - } + dash = json['dash'] != null ? Dash.fromJson(json['dash']) : null; + durl = json['durl']?.map((e) => Durl.fromJson(e)).toList(); supportFormats = json['support_formats'] != null ? json['support_formats'] .map((e) => FormatItem.fromJson(e)) diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index fa9afa29..cbba7cf3 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -229,9 +229,11 @@ class VideoDetailController extends GetxController seekTo: seekToTime ?? defaultST, duration: duration ?? Duration(milliseconds: data.timeLength ?? 0), // 宽>高 水平 否则 垂直 - direction: (firstVideo.width! - firstVideo.height!) > 0 - ? 'horizontal' - : 'vertical', + direction: firstVideo.width != null && firstVideo.height != null + ? ((firstVideo.width! - firstVideo.height!) > 0 + ? 'horizontal' + : 'vertical') + : null, bvid: bvid, cid: cid.value, enableHeart: enableHeart, @@ -252,14 +254,19 @@ class VideoDetailController extends GetxController var result = await VideoHttp.videoUrl(cid: cid.value, bvid: bvid); if (result['status']) { data = result['data']; - if (data.dash == null) { - // isEffective.value = false; - if (data.acceptDesc != null) { - SmartDialog.showToast('当前视频acceptDesc为:${data.acceptDesc},不支持获取视频链接'); - } else { - SmartDialog.showToast('当前视频未能获取视频链接'); + if (data.acceptDesc!.isNotEmpty && data.acceptDesc!.contains('试看')) { + SmartDialog.showToast( + '该视频为专属视频,仅提供试看', + displayTime: const Duration(seconds: 3), + ); + videoUrl = data.durl!.first.url!; + audioUrl = ''; + defaultST = Duration.zero; + firstVideo = VideoItem(); + if (autoPlay.value) { + await playerInit(); + isShowCover.value = false; } - result['status'] = false; return result; } final List allVideosList = data.dash!.video!; diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 766f051d..fcc89322 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -227,7 +227,10 @@ class _VideoDetailPageState extends State @override // 返回当前页面时 void didPopNext() async { - setState(() => isShowing = true); + if (plPlayerController != null && + plPlayerController!.videoPlayerController != null) { + setState(() => isShowing = true); + } videoDetailController.isFirstTime = false; final bool autoplay = autoPlayEnable; videoDetailController