mod: 优化弹幕请求

This commit is contained in:
guozhigq
2023-10-29 00:03:57 +08:00
parent e01292a8f9
commit fd4eb0fad1
2 changed files with 5 additions and 1 deletions

View File

@ -10,6 +10,8 @@ class PlDanmakuController {
// 按 6min 分段
int segCount = 0;
List<DmSegMobileReply> dmSegList = [];
// 已请求的段落标记
List<int> hasrequestSeg = [];
int currentSegIndex = 1;
int currentDmIndex = 0;

View File

@ -95,7 +95,9 @@ class _PlDanmakuState extends State<PlDanmaku> {
// 根据position判断是否有已缓存弹幕。没有则请求对应段
int segIndex = (currentPosition / (6 * 60 * 1000)).ceil();
segIndex = segIndex < 1 ? 1 : segIndex;
if (ctr.dmSegList[segIndex - 1].elems.isEmpty) {
if (ctr.dmSegList[segIndex - 1].elems.isEmpty &&
!ctr.hasrequestSeg.contains(segIndex - 1)) {
ctr.hasrequestSeg.add(segIndex - 1);
ctr.currentSegIndex = segIndex;
EasyThrottle.throttle('follow', const Duration(seconds: 1), () {
ctr.queryDanmaku();