diff --git a/lib/models/video/play/url.dart b/lib/models/video/play/url.dart index 4c43cb00..792cd50d 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 0162654f..d0cf53a6 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 { // 当前可播放的最高质量视频