mod: cid获取
This commit is contained in:
@ -1,7 +1,9 @@
|
|||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:pilipala/common/constants.dart';
|
import 'package:pilipala/common/constants.dart';
|
||||||
import 'package:pilipala/common/widgets/stat/view.dart';
|
import 'package:pilipala/common/widgets/stat/view.dart';
|
||||||
|
import 'package:pilipala/http/search.dart';
|
||||||
import 'package:pilipala/utils/utils.dart';
|
import 'package:pilipala/utils/utils.dart';
|
||||||
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
import 'package:pilipala/common/widgets/network_img_layer.dart';
|
||||||
|
|
||||||
@ -37,9 +39,14 @@ class VideoCardH extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await Future.delayed(const Duration(milliseconds: 200));
|
try {
|
||||||
Get.toNamed('/video?bvid=$bvid&cid=${videoItem.cid}',
|
int cid =
|
||||||
arguments: {'videoItem': videoItem, 'heroTag': heroTag});
|
videoItem.cid ?? await SearchHttp.ab2c(aid: aid, bvid: bvid);
|
||||||
|
Get.toNamed('/video?bvid=$bvid&cid=$cid',
|
||||||
|
arguments: {'videoItem': videoItem, 'heroTag': heroTag});
|
||||||
|
} catch (err) {
|
||||||
|
SmartDialog.showToast(err.toString());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@ -154,4 +154,7 @@ class Api {
|
|||||||
// 记录视频播放进度
|
// 记录视频播放进度
|
||||||
// https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/video/report.md
|
// https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/video/report.md
|
||||||
static const String heartBeat = '/x/click-interface/web/heartbeat';
|
static const String heartBeat = '/x/click-interface/web/heartbeat';
|
||||||
|
|
||||||
|
// 查询视频分P列表 (avid/bvid转cid)
|
||||||
|
static const String ab2c = '/x/player/pagelist';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,4 +80,15 @@ class SearchHttp {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future ab2c({int? aid, String? bvid}) async {
|
||||||
|
Map<String, dynamic> data = {};
|
||||||
|
if (aid != null) {
|
||||||
|
data['aid'] = aid;
|
||||||
|
} else if (bvid != null) {
|
||||||
|
data['bvid'] = bvid;
|
||||||
|
}
|
||||||
|
var res = await Request().get(Api.ab2c, data: {...data});
|
||||||
|
return res.data['data'].first['cid'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,7 +73,6 @@ class SearchVideoItemModel {
|
|||||||
SearchVideoItemModel.fromJson(Map<String, dynamic> json) {
|
SearchVideoItemModel.fromJson(Map<String, dynamic> json) {
|
||||||
type = json['type'];
|
type = json['type'];
|
||||||
id = json['id'];
|
id = json['id'];
|
||||||
cid = json['id'];
|
|
||||||
arcurl = json['arcurl'];
|
arcurl = json['arcurl'];
|
||||||
aid = json['aid'];
|
aid = json['aid'];
|
||||||
bvid = json['bvid'];
|
bvid = json['bvid'];
|
||||||
@ -83,14 +82,13 @@ class SearchVideoItemModel {
|
|||||||
videoReview = json['video_review'];
|
videoReview = json['video_review'];
|
||||||
pubdate = json['pubdate'];
|
pubdate = json['pubdate'];
|
||||||
senddate = json['senddate'];
|
senddate = json['senddate'];
|
||||||
duration = test(json['duration']);
|
duration = _dutation(json['duration']);
|
||||||
// duration = json['duration'];
|
|
||||||
owner = Owner.fromJson(json);
|
owner = Owner.fromJson(json);
|
||||||
stat = Stat.fromJson(json);
|
stat = Stat.fromJson(json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
test(String duration) {
|
_dutation(String duration) {
|
||||||
List timeList = duration.split(':');
|
List timeList = duration.split(':');
|
||||||
int len = timeList.length;
|
int len = timeList.length;
|
||||||
if (len == 2) {
|
if (len == 2) {
|
||||||
|
|||||||
@ -46,15 +46,15 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
_meeduPlayerController = videoDetailController.meeduPlayerController;
|
_meeduPlayerController = videoDetailController.meeduPlayerController;
|
||||||
_playerEventSubs = _meeduPlayerController!.onPlayerStatusChanged.listen(
|
_playerEventSubs = _meeduPlayerController!.onPlayerStatusChanged.listen(
|
||||||
(PlayerStatus status) {
|
(PlayerStatus status) {
|
||||||
// videoDetailController.markHeartBeat();
|
videoDetailController.markHeartBeat();
|
||||||
if (status == PlayerStatus.playing) {
|
if (status == PlayerStatus.playing) {
|
||||||
Wakelock.enable();
|
Wakelock.enable();
|
||||||
isPlay = false;
|
isPlay = false;
|
||||||
isShowCover = false;
|
isShowCover = false;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
// videoDetailController.loopHeartBeat();
|
videoDetailController.loopHeartBeat();
|
||||||
} else {
|
} else {
|
||||||
// videoDetailController.timer!.cancel();
|
videoDetailController.timer!.cancel();
|
||||||
isPlay = true;
|
isPlay = true;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
Wakelock.disable();
|
Wakelock.disable();
|
||||||
|
|||||||
Reference in New Issue
Block a user