From 3d2c6a122ac652712a6ee82f7f16234ad790c5d7 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Fri, 16 Feb 2024 21:30:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E5=85=85=E7=94=B5=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E8=AF=95=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/video/play/url.dart | 31 +++++++++++++++++++++++++- lib/pages/video/detail/controller.dart | 23 ++++++++++++++++--- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/lib/models/video/play/url.dart b/lib/models/video/play/url.dart index 4c43cb007..792cd50d3 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,7 +53,8 @@ class PlayUrlModel { videoCodecid = json['video_codecid']; seekParam = json['seek_param']; seekType = json['seek_type']; - dash = Dash.fromJson(json['dash']); + 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)) @@ -250,3 +252,30 @@ class Flac { audio = json['audio'] != null ? AudioItem.fromJson(json['audio']) : null; } } + +class Durl { + Durl({ + this.order, + this.length, + this.size, + this.ahead, + this.vhead, + this.url, + }); + + int? order; + int? length; + int? size; + String? ahead; + String? vhead; + String? url; + + Durl.fromJson(Map json) { + order = json['order']; + length = json['length']; + size = json['size']; + ahead = json['ahead']; + vhead = json['vhead']; + url = json['url']; + } +} diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index 0162654f8..d0cf53a67 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, @@ -248,6 +250,21 @@ class VideoDetailController extends GetxController var result = await VideoHttp.videoUrl(cid: cid.value, bvid: bvid); if (result['status']) { data = result['data']; + 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; + } + return result; + } final List allVideosList = data.dash!.video!; try { // 当前可播放的最高质量视频 From 740d5f1ddd2d52f48ae3b3dfd5ee60ad59951b7a Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 21 Feb 2024 23:27:32 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E8=A7=86=E9=A2=91=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E7=82=B9=E5=87=BB=E4=B8=BB=E9=A1=B5=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E5=8D=A1=E6=AD=BB=20issues=20#562?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/view.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 14311cc95..3d3158045 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -225,7 +225,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.playerInit(autoplay: autoplay);